Jquery AJAX json - not called
Jquery AJAX json - not called
我无法连接到Web服务,尝试了很多不同的选项并更改了参数,提示在哪里挖掘?这是我第一次体验通过AJAX连接,我尝试通过其他客户端工作。
var xhr = $.ajax({
url: webserUrl,
type: "GET",
data: JSON.stringify({ "Tabn": "1","Vaccurrent": "1","Vacnext": "1" }),
cache: false,
crossDomain: true,
username: "user",
password: "password",
processData: false,
contentType: "application/json",
dataType: "json",
headers: {
"Accept": "application/json; odata=verbose"
},
xhrFields: {
withCredentials: true
},
crossDomain: true,
success: OnSuccess,
error: OnError
});
function OnSuccess(data, status)
{
alert(data);
}
function OnError(xhr, ajaxOptions, thrownError, request, error)
{
alert('xrs.status = ' + xhr.status + ''n' +
'thrown error = ' + thrownError + ''n' +
'xhr.statusText = ' + xhr.statusText + ''n' +
'request = ' + request + ''n' +
'error = ' + error);
console.log('xrs.status = ' + xhr.status + ''n' +
'thrown error = ' + thrownError + ''n' +
'xhr.statusText = ' + xhr.statusText + ''n' +
'request = ' + request + ''n' +
'error = ' + error);
}
});
错误:
xrs.status=200
抛出错误=未定义
xhr.statusText=确定
request=未定义
error=未定义
感谢大家的回答,更改为带有wsdl端点的url,还将内容类型更改为:"text/xml;charset=''"utf-8''",一切正常。
xrs.status = 200
表示服务器接受了请求,因此问题可能发生在客户端,很可能是由"Accept": "application/json; odata=verbose"
标头引起的,该标头指示jquery如果没有发送json作为响应,则拒绝服务器响应。
您需要使用浏览器提供的开发工具来检查服务器响应的数据。
相关文章:
- jQuery is not loaded
- AngularJS JSON not arriving php
- $rootScope not working
- reactRedux is not defined
- jQuery document.ready not working
- Javascript/Jquery Blob not showing Chrome PDF
- jQuery POST not being called
- shouldoverrideurlloading not called Webview Android
- ReactCSSTransitionGroup componentWillLeave not called
- Template.destroyed() not called
- FineUploader OnComplete not being called
- Jquery AJAX json - not called
- JQuery _renderItem not being called
- Sitecore - WebMethod is not being called
- Onclick not being called
- $watch is not called, Angularjs
- Meteor Autoform: methodserver not called
- Angular Function not Called in <span> tag
- XmlHttpRequest.onload not called
- @ Parse.com success/error not called I'我只调用了一次success/er