我正在通过jQuery ajax向.NET通用处理程序(.ashx)发出请求。jQuery ajax请求只能同步工作,不会在异步时返回
我正在返回JSON,我已经在JSONLint上进行了验证,但无法发布,因为它是敏感数据。
问题是调用只在同步完成时返回(async:false
)。当异步完成时,它永远不会回来。 async:false
将调用我的成功功能以及所有全局功能。 async:true
将只调用全局函数ajaxStart
和ajaxSend
,async:false
将调用这些以及其他。
我不知道如何进一步调试或确定为什么没有响应回来。
$.ajax({
type: "POST",
async: false,
cache: false,
timout: 600000,
data: request_object.GetQueryString(),
dataType: "json",
responseType: "json",
error: function (request, error_type, error_message) {
alert("error");
},
success: function (data, status, request) {
alert("success");
},
url: "./ReportRequestHandler.ashx",
complete: function() {
alert("here");
}
});
$(document).ajaxError(function() {
alert("ajaxError");
}).ajaxSend(function() {
alert("ajaxSend");
}).ajaxStart(function() {
alert("ajaxStart");
}).ajaxStop(function() {
alert("ajaxStop");
}).ajaxSuccess(function() {
alert("ajaxSuccess");
}).ajaxComplete(function() {
alert("ajaxComplete");
});
超时时出现拼写错误..也。检查网络面板的萤火虫或在控制台的铬为xhr请求,以便您可以知道是什么问题 –