[英]JQuery ajax get error :unexpected token :
I have to do an ajax get to retrieve data from OData service, this is my code : 我必须做一个ajax获取来从OData服务检索数据,这是我的代码:
$.ajax({
url : "https://systempath/servicename",
type: "GET", //or POST?
dataType: "jsonp",
xhrFields:
{
withCredentials: true
},
beforeSend: function (request)
{
request.setRequestHeader("Authorization", "Basic");
},
success: function(){alert("ok")},
error: function(){alert("error")}
})
But i get this error : 但是我得到这个错误:
Uncaught SyntaxError: Unexpected token :
If i consult the network, i find my response in JSON format, but the error function is executed not the success function. 如果咨询网络,我会以JSON格式找到响应,但执行错误功能而不是执行成功功能。
The issue with your code is the dataType that you defined, make sure that the responses headers are corrects with your req. 代码的问题是您定义的dataType ,请确保响应标头与您的要求正确。 Test with the dataType:'text',
this might works fine. 使用dataType:'text',
可能效果很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.