Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You should read through the <a href="http://api.jquery.com/jQuery.ajax/" rel="nofollow">jquery documentation</a> once more, especially the part that covers the <code>data</code> and <code>dataType</code> parameters. <code>data</code> must be a key/value object, i.e.:</p> <pre><code>data: { 'userid': userid } </code></pre> <p>...and for dataType, allowed values are xml, html, text, json, and jsonp. If your PHP script sends a suitable <code>Content-type</code> header (e.g. <code>header('Content-type: text/json');</code>, then you can simply leave this parameter at the default ('Intelligent guess'). jQuery will infer the response type from its content type header. You should send the header anyway because otherwise, the server will probably assume you're sending HTML and add a HTML content type header itself, which jQuery then chokes on. It's probably also a good idea to set the <a href="http://php.net/manual/en/function.mb-internal-encoding.php" rel="nofollow">internal encoding</a> and <a href="http://www.php.net/manual/en/function.mb-http-output.php" rel="nofollow">output encoding</a> in your PHP script, so that it understands the request correctly and sends a well-formed UTF-8 response.</p> <p>For further debugging, you might want to:</p> <ul> <li>add some logging code to your PHP, for example, dump the <code>$_POST</code> array and the response you're sending to a text file on the server</li> <li>post a test request to your PHP script using something like curl or wget, and see if the response is what you expect</li> <li>have your javascript post to a dummy script that does nothing but log the request and send an empty response; see if that works</li> <li>step through your javascript using a script debugger (e.g. Firebug on Firefox, or the thing that's built into Chrom[e|ium]); set a breakpoint inside the success handler and see if it's hit, and if so, what the response contains</li> </ul>
 

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