Ajaxphp transmits and receives variable implementation ideas and code. So, yourjQuerymightbesomethinglike ..... copy the code as follows: $. ajax ({url: query. php, data: {id: 10}, datatype: jsonsuccess: function (results) {if (results. msgsuc So, your jQuery might be something like .....
The 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 ....
The 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.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/326435.htmlTechArticleSo, your jQuery might be something like ..... the code is as follows: $. ajax ({url: 'query. php ', data: {id: 10}, datatype: json success: function (results) {if (results. msg = 'suc...