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 gojs 点击按钮node的position位置进行改变,再次点击回到原来的位置
  • ¥15 计算决策面并仿真附上结果
  • ¥20 halcon 图像拼接
  • ¥15 webstorm上开发的vue3+vite5+typeScript打包时报错
  • ¥15 vue使用gojs,需求在link中的虚线上添加方向箭头
  • ¥15 CSS通配符清除内外边距为什么可以覆盖默认样式?
  • ¥15 SPSS分类模型实训题步骤
  • ¥100 求ASMedia ASM1184e & ASM1187e 芯片datasheet/规格书
  • ¥15 求解决扩散模型代码问题
  • ¥15 工创大赛太阳能电动车项目零基础要学什么