jQuery.ajax 成功回调函数未执行 [英] jQuery.ajax success callback function not executed
问题描述
我有一个 JavaScript Ajax 调用 (jQuery.ajax),它不执行成功回调函数.
I have a JavaScript Ajax call (jQuery.ajax), that does not execute the success callback function.
$.ajax({
url: target,
contentType: 'application/json; charset=utf-8',
type: 'POST',
// type: 'GET',
dataType: 'jsonp',
error: function (xhr, status) {
alert(status);
},
success: function (result) {
alert("Callback done!");
// grid.dataBind(result.results);
// grid.dataBind(result);
}
});
我在萤火虫中看到,请求已发布,并按预期返回了 json 方面的正确结果.怎么了?
I see in firebug, that the request is posted and the correct result in terms of the json is returned as expected. What is wrong?
推荐答案
很多时候我都遇到过类似的问题,大部分是因为json格式错误.尝试以文本数据类型获取结果,看看这是否是您的问题.
For many times I have encountered similar problems and most of the time the reason was a malformed json. Try getting the result as text data type to see whether this is your problem.
另外,我想问一下您是否使用了像&jsoncallback=?"这样的参数在您的网址中,因为您的数据类型是 jsonp 而不是简单的 json.
Also, I'd like to ask if you're using a parameter like "&jsoncallback=?" in your url, since your data type is jsonp instead of simple json.
这篇关于jQuery.ajax 成功回调函数未执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!