title: Why am I not gettiing anything when I click the submit button?
body: <p>This is the html code..</p>
  
  <pre><code>    &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
      $(document).ready(function(){
          $("#button").click(function(){
              var senda=$("#ans").val();
              $.ajax({
                  type:"POST",
                  url:"ajax.php",
                  data:{"answer":"senda"},
                  dataType:"json",
                  success: function()(msg,string,jqXHR){
                      $("#result").html(msg+string+jqXHR);
                  }
              });
          });
      });
  
  
  
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  Hey what has a head and a tail but no body?
  &lt;input type="text" id="ans" name="ans" /&gt;
  &lt;input type="button" id="button" value="submit" /&gt;
  &lt;p&gt;&lt;div id="result"&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and this is the code of the php file ajax.php:-</p>
  
  <pre><code>&lt;?php 
  
  $y=$_REQUEST['answer'];
  echo "hey $y ";
  if($y=='coin'){
      echo "hey it worked";
  }
  
  ?&gt;
  </code></pre>
  
  <p>Please tell me where I am going wrong.The html code runs fine initially but when I click the submit button nothing happens. I now this might be just very beginner kinda question,actually I am just learning Jquery and php. What I am actually trying to do is take an input from the user and check if the input matches a string and then take the user to a new page.So any help would be much appreciated.</p>