关于有效json的Parseerror

时间:2013-11-18 22:08:52

标签: jquery ajax json

我正在使用http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js

我在使用ajax应用程序时遇到了一些麻烦: 我在json上得到一个解析错误,但是json数据是有效的(我在http://jsonformatter.curiousconcept.com/验证了它)

我对jQuery知之甚少,所以我正在寻求帮助:

我正在调用此函数:

{
    ...

    var jqxhr = $.post(url,{
        month: mois,
        year: annee,
        itemId: gtritemid
        },function(data){
            alert('success');
        }
    );
    return false;
}

我还声明了ajaxSetup,以便了解会发生什么:

$(function() {
    $.ajaxSetup({
        error: function(jqXHR, exception) {
            if (jqXHR.status === 0) {
                alert('Not connect.\n Verify Network.');
            } else if (jqXHR.status == 404) {
                alert('Requested page not found. [404]');
            } else if (jqXHR.status == 500) {
                alert('Internal Server Error [500].');
            } else if (exception === 'parsererror') {
                alert('Requested JSON parse failed.');
            } else if (exception === 'timeout') {
                alert('Time out error.');
            } else if (exception === 'abort') {
                alert('Ajax request aborted.');
            } else {
                alert('Uncaught Error.\n' + jqXHR.responseText);
            }
        }
    });
});

json是有效的,为什么不能jquery解析json?

0 个答案:

没有答案
相关问题