jQuery JSON drop down not populating

Invenuecomemy

New Member
I am trying to create a drop down list using jQuery, PHP and mySQL, here is my code thus far,HTML: \[code\]<select id="box"></select><br /><input id="button" type="button" value="http://stackoverflow.com/questions/3607026/populate" />\[/code\]Javascript/jQuery:\[code\]$(document).ready(function() { $("#button").click(function (){ $.getJSON("test_post.php", function(data){ $.each(data, function(user) { $('#box').append( $('<option></option>').html(user) ); }); }); });});\[/code\]PHP:\[code\]mysql_connect('localhost', 'user', '1234');mysql_select_db('json');$test = mysql_query('SELECT user,pass FROM login WHERE user="john"');while($row = mysql_fetch_array($test, true)) { $data .= json_encode($row);};echo $data;\[/code\]I have 3 entries in the database, and when I run the 'test_post.php' file, it echoes out the JSON, but when I try and get it to populate the drop down, nothing happens!Any idea why?
 
Back
Top