Note that there are some explanatory texts on larger screens.

plurals
  1. PONo SQL data returned through jQuery ajax post
    primarykey
    data
    text
    <p>I am having some issues returning data from on page, using jQuery, PHP and MySQL. I would like to show the query results on the index.php page. The results are fetched from the database using getResults.php.</p> <p>When I manually run the getResults.php?id=123 file, all works fine. In this case i'm seeing the results I would like to. However, when I want to post the 'id' 123 in a submit form on index.php, I don't see any results returned by jQuery / getResults.php. Only thing that changed is the URL: index.php?id=123. However, I'm not seeing any results or an error message...</p> <p>Any one an idea?</p> <p>getResults.php file</p> <pre><code>$search = mysql_real_escape_string( isset ($_POST['id'])); if ($search) { $friend = mysql_query( " SELECT * FROM reviews WHERE fbuserid = '$search' ORDER BY datumtijd DESC" ); if ( $friend ) { while ($row = mysql_fetch_array ($friend) ) { echo "Show some results..."; } } else { echo "No matches found"; } } else { echo "Query not succesfull"; } </code></pre> <p>index.php file</p> <pre><code>&lt;script type="text/javascript" charset="utf-8"&gt; $(document).ready(function() { $("#submit").click(function) { event.preventDefault(); $.ajax({ url:"getResults.php", type:"GET", data: "id="+this.value, success: function(data) { $("#results").html(data); } }); } return false; }); &lt;/script&gt; &lt;div&gt; &lt;form&gt; &lt;input type="text" name="id"&gt; &lt;input type="submit" value="submit" id="submit"&gt; &lt;/form&gt; &lt;/div&gt; &lt;div id="results"&gt;&lt;/div&gt; </code></pre> <p>EDIT: Thanks, all for your input. Nevertheless, I'm still not there... As you might notice, I'm not quite experienced with jQuery and PHP. See changes in scripts above. In short: - I added the false statement if ($query) is not succesfull; - Changed the $.post method into $.ajax; - Changed the GET into POST in the PHP file;</p> <p>Any other suggestions? </p>
    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.
 

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