Note that there are some explanatory texts on larger screens.

plurals
  1. POAJAX no data showing up from server request
    primarykey
    data
    text
    <p>I am tryng to get AJAX to post to a seperate php file and then have that data put into a div. The ultimate goal will be to set up a long poll for auto updating, but baby steps.</p> <p>So nothing shows up in the div when the page is loaded. I checked the console and the ajax does send the 'initiate' POST but it doesn't seem to receive anything back except headers.</p> <p><em>FIXED</em> whole time i was missing curly brackets. Thanks for all the syntax help guys.</p> <p>here is the code</p> <p>Php file that ajax calls</p> <pre><code>&lt;?php require "dbc.php"; $function = $_POST['function']; switch($function) case('initiate'): $search="SELECT * FROM Feedtest ORDER BY id DESC"; $request = mysql_query($search); $mostrecent= mysql_fetch_array($request); $mostrecentid = $mostrecent['id']; header("Content-type: application/json"); echo json_encode($mostrecentid); break; case('update'): $search="SELECT * FROM Feedtest ORDER BY id DESC"; $request = mysql_query($search); $update= mysql_fetch_array($request); $updateid = $update['id']; header("Content-type: application/json"); echo json_encode($updateid); break; ?&gt; </code></pre> <p>The page where the call is made </p> <pre><code>&lt;div id="datacheck"&gt;&lt;/div&gt; &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).ready(function() { $.ajax({ type: 'POST', url: 'feedupdate.php', data: {function: 'initiate'}, dataType: "json", success: function(msg) { $('#datacheck').html(msg); } }); }); // document ready &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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. 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