我有一个JSON字符串与我{offer.offer.offerId.USSellerId:{$ GT:50}}。我所要做的就是使用这个json查询作为有效负载调用POST REST服务并获取返回的JSON。阿贾克斯后返回Object {readyState的= 0,状态= 0,状态文本= “错误”}
我能够使用先进的铬其余客户端调用该服务,我找回数据。但我的问题是,当我尝试使用下面的代码行来调用这个服务,我得到以下错误
$.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)
}
});
我在控制台看到以下内容:
对象{readyState的= 0,状态= 0,状态文字=“错误”} 错误 emptry字符串..
我无法理解此错误。当我没有谷歌这个错误,许多建议告诉它可能是跨浏览器问题。我无法控制服务器端代码。
我该如何修复客户端的跨浏览器错误?
你检查'内容type' http头?如果你真的在发送json数据,你应该在'ajax'设置中指定正确的'contentType',因为jQuery使用'application/x-www-form-urlencoded'作为默认的内容类型,参见[documentation](http:// api.jquery.com/jquery.ajax/)。 – 2014-09-13 20:08:42
嗨IIya,我改变了我的jQuery的岗位AJAX,但这个时候,我得到一个奇怪的错误回到它没有什么可说的:( – user3773712 2014-09-13 23:04:28
最有可能您的要求甚至不会现在送两件事情 - 包装您的数据对象在'JSON.stringify()'中,并在控制台中寻找错误 – 2014-09-14 07:24:52