我真的變得如此沮喪與這個jQuery, 我想o使用的getJSON我的AJAX但它只是不工作!其驅使我堅果。JSON和jQuery不工作
$.ajax({
type: "GET",
url: '../file.php',
data: param,
async: true,
beforeSend: function(x) {
if(x && x.overrideMimeType) {
x.overrideMimeType("application/j-son;charset=UTF-8");
}
},
dataType: "json",
success: function(data){
//do your stuff with the JSON data
alert("called");
}
});
兩者都只是不工作,它沒有得到的回覆:
我有這個,有這個從一個例子:
$.getJSON("../file.php",{filepath:g_filepath, startRow: "0"},dates);
而且這一點。
有人可以幫助我。
在我的PHP文件中的代碼是這樣的:
$myArray = array();
while($filehandle->eof) {
$line = $filehandle->fgets();
array_push($myArray, $line);
echo json_encode($myArray);
}
我在錯誤做什麼呢?
你確定服務器返回什麼嗎? – Joseph 2012-03-07 06:26:26
不要發明MIME類型。 'application/json'是正確的。 – kapa 2012-03-07 06:28:09
服務器可能會返回錯誤?使用Chrome開發人員工具或類似的請求/響應看看 – jgauffin 2012-03-07 06:29:51