【发布时间】:2018-07-09 09:58:15
【问题描述】:
我有一个 REST 入口点嵌入到一个带有注释 @RestController 的类中:
@RequestMapping(value = "/test", method = RequestMethod.GET, produces="application/json")
public String getReitByDateRangeAdDoGeographic(){
return "{\"msg\":\"success\"}";
}
我尝试使用 ajax 请求来请求它:
$.ajax({
dataType: "jsonp",
url: URL,
success: function(data) {
console.log("SUCCESS");
},
error: function (a,b, result) {
console.log("ERROR");
console.log(a);
console.log(b);
console.log(result);
}
});
当我在浏览器中查看http响应时,它是正确的:
{
"msg": "success"
}
但错误回调总是与消息一起调用(HTTP 代码为 200):
14:19:00,855 Error: jQuery1113010493236335514322_1517318340103 was not called
Trace de la pile :
.error@http://localhost:63342/Sankey/external-lib/jquery/jquery-1.11.3.min.js:2:1809
b.converters["script json"]@http://localhost:63342/Sankey/external-lib/jquery/jquery-1.11.3.min.js:5:27779
Pb@http://localhost:63342/Sankey/external-lib/jquery/jquery-1.11.3.min.js:5:18379
x@http://localhost:63342/Sankey/external-lib/jquery/jquery-1.11.3.min.js:5:21793
.send/b.onreadystatechange@http://localhost:63342/Sankey/external-lib/jquery/jquery-1.11.3.min.js:5:27067
1 generateSankey.js:22:3
你知道为什么吗?是解析问题吗?
【问题讨论】:
标签: javascript jquery ajax jsonp