Note that there are some explanatory texts on larger screens.

plurals
  1. POForm result in Same page
    text
    copied!<p>I have visited the following <a href="https://stackoverflow.com/questions/1218245/jquery-submit-form-and-then-show-results-in-an-existing-div"> Link </a></p> <p>Now i have 2 Sample files Contents of test2.php</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt; Form &lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;?php include_once("test.php"); ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Content of test.php</p> <pre><code>&lt;?php if (isset($_POST['submit'])) { $arr=array(); foreach ($_POST as $key =&gt; $value) { $arr[$key]=$value; } print_r($arr); } ?&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt; Form &lt;/title&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"&gt; &lt;/script&gt; &lt;link rel="stylesheet" href="css/main.css" /&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="content" id="login_form"&gt; &lt;form method="post" id="f1" name="f1" action="test.php"&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;Name :&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="name"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Register Number :&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="regno"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Date of Birth :&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="dob"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="submit" id="b1" name="submit" value="Submit" style="font-size:16px;"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/div&gt; &lt;script&gt; $('#f1').submit(function() { $.ajax({ data: $(this).serialize(), type: $(this).attr('post'), url: $(this).attr('test.php'), success: function(response) { $('#content').html(response); } }); return false; }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>test2.php displays the form.<code>I want to display the values entered in the form and the form</code> after I click submit but I keep seeing the form only. is it because $_POST is empty or because I have made mistakes in the structure of the page itself?</p> <p>Edit : I want the result of the form submit loaded in test2.php page.</p>
 

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