title: Getting the value via AJAX, PHP
body: <p>I have an ajax function with three parameters. The first parameter holds the url that the ajax function go to when it's called. The second parameter contains the id name of the div containing the eventual output. The third parameter contains a variable that can be stored in POST to be sent to the url that the ajax function go to when it's called, so that it can be echoed, and sent to the div with the id 'output' on the original page. </p>
  
  <p>My question is: Are there any ways to get the value in the input type submit, so that it can be stored in POST to be sent to the url that the ajax function go to when it's called, so that it can be echoed, and be seen in the div with the id 'output' on the original page? </p>
  
  <p>So the value in the input type submit would be "submit". </p>
  
  <p><b> test1.php </b></p>
  
  <pre><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;script type = "text/javascript"&gt; 
  
  function ajaxPass(gotoUrl,output,input) {
  
        $.ajax({
             type: "POST",
             url: gotoUrl,
             data: { input : input },
             error: function(xhr,status,error){alert(error);},
             success:function(data) {
               document.getElementById( output ).innerHTML = data;
             }
  
        });
  
  }
  
  &lt;/script&gt;
  
  &lt;input type = "submit" name = "submit" value = "submit" onclick = "ajaxPass('test2.php','output','input')"&gt;
  &lt;div id = 'output'&gt; &lt;/div&gt;
  </code></pre>
  
  <p><b> test2.php </b></p>
  
  <pre><code>&lt;?php
  
  $input = $_POST['input'];
  echo $input;
  
  ?&gt;
  </code></pre>