weixin_33675507 2012-11-28 17:35 采纳率: 0%
浏览 35

发送ajax请求phonegap

I d' like to send an ajax request on a website but I have a strange result:

$.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 is

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

So I have the alert fail but im my console.log I have the content of my json file

Why the error return a result ??

Thanks

  • 写回答

1条回答 默认 最新

  • weixin_33724059 2012-11-28 18:25
    关注

    Try this sample:

    $.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 !!!');
        },
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 一道python难题2
  • ¥15 一道python难题
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备