Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The data that is output by PHP during an AJAX request will be in the <code>data</code> variable of your <code>success</code> callback function. If you want to append the data onto your page, you'll need to do so in your success function.</p> <pre><code>$.ajax({ type: "POST", url: "bin/process.php", data: dataString, cache:false, success: function(data) { // the data variable contains all PHP output during this request $('#display').html(data); } }); </code></pre> <p>Also note, your script currently specified that it is a JSON request - that jQuery ought to treat the output as JSON data. However, you are outputting text/html data in your PHP snippet. Either a) append your html into one variable, then call <code>print json_encode($mydata);</code>, OR b) remove the <code>datatype</code> property from the request. jQuery will "auto-detect" the response type. The above example is assuming you do NOT change the PHP code, below is details on how to correctly use JSON instead (change to PHP required).</p> <p>To do the JSON method, instead of using <code>echo</code>, use a variable:</p> <pre><code>$html = ''; $html .= 'Doctype: '.$doctype; $html .= 'Something elese: '.$something_else; // etc... die(json_encode(array('html'=&gt;$html))); </code></pre> <p>Then your jQuery ajax function looks like this:</p> <pre><code>$.ajax({ type: "POST", url: "bin/process.php", data: dataString, cache:false, datatype: 'json', success: function(data) { $('#display').html(data.html); } }); </code></pre>
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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