jQuery AJAX类型:'GET'用PHP制造问题


jQuery AJAX type: 'GET' make problems with PHP

直到今天早上我才尝试从Mysql和ajax中检索数据。

这是我的代码:

HTML:

$.ajax({
   //type:'GET',
   url: "/lecture_message_pilote.php",
   data: ({location_id:zlid}),
   contentType: "application/json; charset=utf-8",
   dataType: 'json',                //data format
   success: function(data)          //on recieve of reply
   {
       var zidpilote = data[0];              //get id
       var zmessage = data[1];           //get name
       alert(zmessage);
   }
});

和PHP:

$result = mysql_query("select * from Test_phoneGAP_message where IDPILOTE = '".$location_id."'");
$array = mysql_fetch_row($result);  
echo (json_encode($array));
mysql_close();

我有错误信息:UNDEFINED for alert(zmessage);如果我使用PHP请求:

$result = mysql_query("select * from Test_phoneGAP_message");

我有一个好的结果。我想我的PHP不接受$location_id

尝试通过php的$_REQUEST["location_id"]元素访问该参数。

$result = mysql_query("select * from Test_phoneGAP_message where IDPILOTE = '".$_REQUEST["location_id"]."'"); $array = mysql_fetch_row($result);