weixin_33739646 2019-12-15 09:13 采纳率: 0%
浏览 93

调试Ajax请求

I have a cordova app and I am making ajax calls to the server and I want to see the response. There is fail which gets called and it returns me response error and I want to properly evaluate that error response. For that, I created a div and populates the error responses into that but all I get on my mobile screen is this: [Object object]. I want to expand this object to see everything since I don't know what is residing in this object. This is my ajax call:

function getUserDefaultWalletUpdatedBalance()
{
    $.ajax(
    {
        url: request_url('get-default-wallet-balance'),
        type: "get",
        data:
        {
            'user_id': window.localStorage.getItem('user_id'),
        },
        dataType: 'json',
        beforeSend: function(xhr)
        {
            xhr.setRequestHeader('Access-Control-Allow-Methods', 'GET');
            xhr.setRequestHeader('Authorization-Token', `${window.localStorage.getItem('token')}`);
            $('.loader').css('display', 'block'); //show loader
        },
    })
    .done(function(data)
    {
        $('.loader').css('display', 'none'); //hide loader        
        $('.profileDiv').css('display', 'block'); //show page

        if (data.success.status == 200)
        {
            // console.log(data.success);

            $(".av_blance").text(data.success.defaultWalletBalance);
        }
    })
    .fail(function(error)
    {
        $('.loader').css('display', 'none'); //hide loader
        $('.my').text(error);
    });
}
  • 写回答

1条回答 默认 最新

  • weixin_33705053 2019-12-15 10:19
    关注

    Here is the answer:

    Json.stringify(error) 
    

    solves the issue for me.

    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记