Jquery 在sharepoint 2010中,ajax在chrome中返回错误
我正在使用rest从sharepoint 2010列表中检索数据,jquery ajax使用../\u vti\u bin/listdata.svc。代码如下:Jquery 在sharepoint 2010中,ajax在chrome中返回错误,jquery,ajax,json,google-chrome,sharepoint-2010,Jquery,Ajax,Json,Google Chrome,Sharepoint 2010,我正在使用rest从sharepoint 2010列表中检索数据,jquery ajax使用../\u vti\u bin/listdata.svc。代码如下: $.ajax({ type: "GET", url: "../_vti_bin/listdata.svc/"+listName+"?$select=Title", contentType: "application/json; charset=utf-8",
$.ajax({
type: "GET",
url: "../_vti_bin/listdata.svc/"+listName+"?$select=Title",
contentType: "application/json; charset=utf-8",
dataType: "json",
beforeSend: function (XMLHttpRequest) {
//Specifying this header ensures that the results will be returned as JSON.
XMLHttpRequest.setRequestHeader("Accept", "application/json");
},
success: generateCarousal,
error: alertError,
//complete:afterCompletion
});
function generateCarousal(data)
{
if(data.d.results.length>0)
{
var carousalDiv=item.Title;
}
else
{ alert("Data not found")}
}
function alertError(jqXHR)
{
if (jqXHR.status == 200 && jqXHR.statusText == "OK") {
alert(typeof jqXHR.responseText)
}
else {
alert(JSON.stringify(jqXHR));
}
}
这在IE中运行良好,即我成功获得json对象,但对于chrome,它进入错误状态,状态为200,状态为“ok”。而且responsetext以字符串格式提供正确的数据,我无法使用jquery.parseJson将其转换为json
有人能解释一下为什么它不能在chrome中工作,以及可能的解决方案是什么吗?在调用中尝试成功代码
success: function(data) {
//Write your code here
if(data.d.results.length>0)
{
var carousalDiv=item.Title;
}
else
{
alert("Data not found")
}
},
error: function() {
alert('An error occurred');
}
希望它有帮助在通话中尝试成功代码
success: function(data) {
//Write your code here
if(data.d.results.length>0)
{
var carousalDiv=item.Title;
}
else
{
alert("Data not found")
}
},
error: function() {
alert('An error occurred');
}
希望它有帮助它在ie中工作,但在chrome中不工作。所以我需要同样的东西也在chrome中工作。你是否尝试过在ajax调用中编写成功代码,而不是像我前面的例子中那样定义另一个函数?我在Firefox中遇到了同样的问题。它在ie中工作,但在chrome中不工作。所以我需要同样的东西也在chrome中工作。你是否尝试过在ajax调用中编写成功代码,而不是像我前面的例子中那样定义另一个函数?我在Firefox中遇到了同样的问题。它在ie中工作,但在chrome中不工作。所以我需要同样的东西在chrome中也可以使用。你是否尝试过在ajax调用中编写成功代码,而不是像我前面的例子中那样定义另一个函数?我在firefox中遇到了同样的问题