[英]The data is not received by method $.ajax success in ie9
在ie9中,成功方法僅通過兩個參數接收:textStatus和XMLHttpRequest。 數據始終是未定義的。 在其他所有其他瀏覽器中,代碼都可以正常運行,並且所有3個參數都發送給成功方法。 結果,完成后,我無法處理任何ajax請求。 可能是什么原因呢?
這是方法代碼的一部分:
SendAjax = function(async, type, act, t, datas)
{
var datatype = 'html';
if (type=='reload_weather' || type=='popup' || act == 'set_location')
datatype = 'json';
var result = 0;
$.ajax({
url: '_ajax/',
data: {act:act, type:type, datas:datas},
type: "POST",
dataType: datatype,
cache: false,
async: async,
success: function(data, textStatus, XMLHttpRequest)
{
printArray(arguments);
/*
{
"1": "success",
"2": {
"readyState": 4,
"status": 200,
"statusText": "OK"
}
}
*/
printArray(data);
/*
undefined
*/
}
}
}
通過將以下行添加到接收請求的php-file中,可以解決此問題:
header('Content-type: text/html; charset=utf-8');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.