So, your jQuery might is something like .....
Copy CodeThe code is as follows:
$.ajax ({
URL: ' query.php ',
Data: {id:10},
Datatype:json
Success:function (Results) {
if (results.msg = = ' success ') {
for (var i in data) {
$ (' #content '). Append (
' id = ' + results.data[i].id + ', description = ' + Results.data[i].description + ', MSRP = ' + RESULTS.DATA[I].MSRP
);
}
} else {
$ (' #content '). Append (results.msg);
}
}
});
And your PHP ....
Copy CodeThe code is as follows:
if (Isset ($_get[' id ')) {
$sql = "SELECT ID, Description, MSRP from TBL WHERE id = ' {$_get[' id ']} '";
$return = Array ();
if ($result = mysql_query ($sql)) {
if (mysql_num_rows ($result)) {
$return [' msg '] = ' success ';
while ($row = Mysql_fetch_assoc ($result)) {
$return [' data '] [] = $row;
}
} else {
$return [' msg '] = ' No results found ';
} else {
$return [' msg '] = ' Query failed ';
}
Header ("Content-type:application/json");
echo Json_encode ($result);
}
http://www.bkjia.com/PHPjc/326435.html www.bkjia.com true http://www.bkjia.com/PHPjc/326435.html techarticle So, your jQuery might is something like ..... Copy the code as follows: $.ajax ({url: ' query.php ', data: {id:10}, Datatype:json success:function (results) {if (results.msg = = ' suc. .