Q:

Retrieving JSON response in jQuery

I'm trying to retrieve the response of this script:
<?php
require_once("db_connect.php"); 
$get = mysql_query("SELECT name FROM main");
$genres;
while ($row = mysql_fetch_array($get)) {
    $genres[] = $row['name'];
}
echo json_encode($genres); 
?>

And get it back in javascript and store it in a variable, so when I do variable[i] in a loop I'll get the ith genre name. 

A:

See http://api.jquery.com/category/ajax/
And also:

Parsing jQuery data in JavaScript (JSON)
How to use JSON with Jquery?
Retrieving JSON with JQuery
How to JSON data using $.getJSON from a php file?

A:

It appears that you have the PHP script setup correctly. Take a look at jQuery's getJSON() method.

A:

$.getJSON('your_script.php', function(genres) {
    // here genres[i] is your i'th genre from the list
});

