阿贾克斯后返回Object {readyState的= 0,状态= 0,状态文本="错误"} [英] ajax post returns Object { readyState=0, status=0, statusText="error"}

查看:1636
本文介绍了阿贾克斯后返回Object {readyState的= 0,状态= 0,状态文本="错误"}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JSON字符串,我{offer.offer.offerId.USSellerId:{$ GT:50}}。所有我想做的事是调用POST REST服务与此JSON查询的负载,并得到返回的JSON。

I have a json string with me {offer.offer.offerId.USSellerId: {$gt: 50}}. All i wanted to do was to call a POST REST Service with this json query as payload and get the returned JSON.

我能够使用先进的镀铬其余客户端调用服务,我得到的数据备份。但我的问题是,当我试图拨打使用低于code线这个服务,我得到了以下错误

I was able to call that service using chrome advanced rest client and I get the data back. But my problem is when I tried to call this service using below line of code I get the following errors

    $.ajax({
        url:"http://10.242.172.12:8080/cqs/services/services/cqs/search",
        Accept: "application/json",
        type: "POST",
        contentType: "application/json",
        data: {"offer.offer.offerId.USSellerId": {"$gt": 50}},
        async:true,
        crossDomain: true,
        always: function(data, textStatus, errorThrown) {
         console.log(data)
         console.log(textStatus)
        },
        success: function (data) {
            console.log(data)
            alert(data);
        },
        error: function (data, status, err) {
            console.log(data)
            console.log(status)
            console.log(err)
        }
    });

我在控制台中看到以下内容:

I see the following in the console:

{对象的readyState = 0,状态= 0,状态文本=错误} 错误 emptry字符串。

Object { readyState=0, status=0, statusText="error"} error emptry string..

我不明白这个错误什么。当我做了谷歌这个错误,很多建议,告诉它可能是跨浏览器的问题。我有超过服务器端code没有控制权。

I could not understand anything from this error. When i did google this error, many suggestion tell that it could be cross browser problem. I have no control over server side code.

我该如何解决,从客户端的跨浏览器的错误?

How can i fix that cross browser error from client side?

推荐答案

请检查的 XMLHtt prequests被停止

如果你结束了一个XMLHtt prequest有状态的 = 0 并   状态文本=零,这意味着该请求没有被允许为   执行。这是UNSENT。这样做的一个可能的原因是当   XMLHtt prequest原点(在创建的XMLHtt prequest)有   当XMLHtt prequest然后打开变()。这种情况下,可能发生   例如,当一个人有一个 XMLHtt prequest是被炒鱿鱼上   onunload事件为窗口:在XMLHtt prequest得到实际上创建   当要关上窗户仍然存在,然后该请求是   发送(即开放式())当此窗口已经失去了重心,并可能   不同的窗口获得了焦点。避免这个问题的方法是将   在新窗口中设置一个侦听器,被设置在激活事件   旧的窗口有其卸载事件触发。

If you end up with an XMLHttpRequest having status=0 and statusText=null, it means that the request was not allowed to be performed. It was UNSENT. A likely cause for this is when the XMLHttpRequest origin (at the creation of the XMLHttpRequest) has changed when the XMLHttpRequest is then open(). This case can happen for example when one has an XMLHttpRequest that gets fired on an onunload event for a window: the XMLHttpRequest gets in fact created when the window to be closed is still there, and then the request is sent (ie open()) when this window has lost its focus and potentially different window has gained focus. The way to avoid this problem is to set a listener on the new window "activate" event that gets set when the old window has its "unload" event fired.

这篇关于阿贾克斯后返回Object {readyState的= 0,状态= 0,状态文本="错误"}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆