-1
在我的javascript我有,
$.ajax({
type: 'GET',
url: 'http://133.333.33.33/reporting/summary_table.php?loc_id='+locid+'&loc_type='+loctype+'',
async: false,
success: function(data) {
alert(data);
},
dataType: 'json'
});
在我的服務器端我有這個,
$result = mysql_query($query);
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
$rows[] = $row;
}
echo json_encode($rows);
當我檢查我的FF螢火蟲,Ajax響應是什麼,它激發出一個錯誤,而不是。我錯過了什麼?
除非服務器支持並啓用CORS,否則無法進行跨域Ajax調用。或者你必須使用JSONP,它也必須得到服務器的支持。 – 2013-02-21 17:28:49
「它會發出錯誤,而不是」 - **什麼**錯誤? – Quentin 2013-02-21 17:29:33
您正在使用[an **過時的**數據庫API](http://stackoverflow.com/q/12859942/19068),並應使用[現代替換](http://php.net/manual/en/ mysqlinfo.api.choosing.php)。 – Quentin 2013-02-21 17:30:34