Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Damm, beaten to the answer!</p> <p>The reason why you were getting a "process_form.php" aborted message in Firebug was from your page refreshing itself before the "process_form.php" could reply to the original query, hence it was aborted! If there's no action in the FORM statement, the page assumes a refresh.</p> <p>For my pennies worth, I try and avoid using jQuery to event handles such as POST and GET, since normally the page then tries a refresh (since no action was declared in the form statement).</p> <p>I use the following code for the client side, with the PHP returning a formatted XML document.</p> <pre><code>&lt;body&gt; &lt;form id="subscription"&gt; &lt;input id="1" value="1"&gt; &lt;input id="2" value="2"&gt; &lt;input id="3" value="3"&gt; &lt;input id="4" value="4"&gt; &lt;input type="button" value="SUBMIT" onclick="submitForm()"&gt; &lt;/form&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { }); function submitForm() { $.post("./process_form.php", $('#subscription').serialize(), function(xml) { alert($("SUCCESS",xml).text()); }, "xml"); }; &lt;/script&gt; &lt;/body&gt; </code></pre> <p>Server side PHP:</p> <pre><code>&lt;?php header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" ); header("Cache-Control: no-cache, must-revalidate" ); header("Pragma: no-cache" ); header("Content-Type: text/xml; charset=utf-8"); $XML = '&lt;?xml version="1.0"?&gt;'; $XML .= "&lt;ROOT&gt;"; $XML .= "&lt;SUCCESS&gt;1&lt;/SUCCESS&gt;"; $XML .= "&lt;/ROOT&gt;"; echo $XML; ?&gt; </code></pre> <p>This allows for validation at the server side easily and for the validated answer to be returned easily. (For example: validating against a database, return with SUCCESS=0 and the reason why REASON=Not in database.)</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