$.ajax({
type: "GET",
dataType: "jsonp",
jsonpCallback: "jsoncallback",
//async: false ,
data:
{
// some data here
},
url: "http://mydomain.com/checkRequest.php",
success: function(data){
alert("123");
alert(data.data.NameA);
},
error: function(jqXHR, textStatus){
alert("Request failed: " + textStatus);
}
});// end of ajax
我可以从下面的 URL 中获取以下字符串,
([{
"data": {
"Rate": "",
"RoleA": "Student",
"NameA": "studentD",
"RoleB": "Tutor",
"NameB": "tutorB",
"Give": "0",
"Get": "1",
"Accept": "0",
"RateCounter": ""
}
}
]);
http://mydomain.com/checkRequest.php?callback=jsoncallback&nameB=tutorB&roleB=Tutor&get=1&roleA=Student&nameA=studentD&give=0&_=1364082750444
但是,它会发出警报parsererror
。请问哪里出了问题?
如果我删除 jsonpCallback: "jsoncallback",
并更改URL
为 url:"http://mydomain.com/checkRequest.php?jsoncallback=?",
没有解析器错误,但它不能alert(data.data.NameA);