jQuery.ajax没有执行成功的回调函数 [英] jQuery.ajax success callback function not executed

查看:648
本文介绍了jQuery.ajax没有执行成功的回调函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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);
        }
    });

我在Firebug看到,该请求被公布,并正确的结果在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆