Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>$(function() { $('#submit').click(function() { var dataString = $('#form1').serialize(); $.ajax({ type: 'POST', url: 'p2.php', data: dataString, success: function(data2) { alert('works!'); // ADDED AFTER UPDATE $('#testResult').html(data2); }, /* ADDED AFTER UPDATE */ error:function(obj,status,error) { alert(error); } }); return false; }); }); </code></pre> <p><strong>Edit:</strong> In p2.php:</p> <pre><code>&lt;?php var_dump($_POST['pw']); ?&gt; </code></pre> <p>In p2.php you then need to output ( using echo, for example) what you want to be returned as 'data2' in your ajax success call.</p> <p><strong>UPDATE:</strong></p> <p>Since you're Ajax request fires succesfully, that means either your post is not passed correctly, or you're not outputting anything. I've re-looked at your code and I saw this:</p> <pre><code>&lt;input type='text' name='input1' id='input1' size='30' /&gt; </code></pre> <p>that means you're fetching the <strong>wrong</strong> $_POST variable!</p> <p>Do this:</p> <ol> <li><p>Since you're sending a name="input1", in your p2.php try with:</p> <pre><code>&lt;?php if(isset($_POST['input1']) { echo $_POST['input1']; } else { echo 'No post variable!'; } </code></pre> <p>And in your jquery success:</p> <pre><code>success: function(data2) { alert(data2); $('#testResult').html(data2); }, </code></pre></li> <li><p>That oughta work, if you follow it literally. In the remote possibility it won't work, forget AJAX, remove the javascript and do a normal post submitting with p2.php as an action of your form :)</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload