【问题标题】:send an ajax request phonegap发送 ajax 请求 phonegap
【发布时间】:2012-11-28 17:35:41
【问题描述】:

我想在网站上发送一个 ajax 请求,但结果很奇怪:

$.ajax({
    type: 'GET',
    url: 'http://mydomain.com/test.json',
    success: function(data){
        console.log(data);
        alert('Ok');
    },
    error: function(data){
        console.log(data.responseText);
        alert('FAIL !!!');
    }
});

test.json 是

{
    ttt: 1,
    ttt: 3,
    test:{
        aa: 1,
        bb: 2
    }
}

所以我的警报失败了,但我的 console.log 我有我的 json 文件的内容

为什么错误返回结果??

谢谢

【问题讨论】:

    标签: android ajax cordova


    【解决方案1】:

    试试这个示例:

    $.ajax({
        type: 'GET',
        url: 'http://mydomain.com/test.json'}),
        success: function(data){
            console.log(data);
            alert('Ok');
        }),
        error: function(jqXHR, textStatus, errorThrown){
            console.log(textStatus);
            alert('FAIL !!!');
        },
    });
    

    【讨论】:

    • 感谢您的帮助,感谢您我看到我的 json 格式错误。
    • 很高兴能帮到你!
    猜你喜欢
    • 2012-12-04
    • 1970-01-01
    • 2013-10-20
    • 1970-01-01
    • 2020-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多