jquery - Jquery Ajax Call Rest API 响应为 200 但它抛出错误
问题描述
设置:Spring Boot Rest API - 响应List<Object>
前端:带有 jQuery 的 Html:Ajax 调用
@GetMapping(value = "/getcall")
@ResponseBody
public List<Ratio> getCall(@RequestParam("date") String date, HttpServletRequest request,
HttpServletResponse response) {
return nseCache.getRatio(date);
}
HTML 调用:
function getall(){
debugger;
$.ajax({
cache: false,
contentType: "application/javascript",
url: "http://localhost:8080/jsonparser/getcall?date=14-Jan-2021",
type: 'GET',
headers: {'Access-Control-Allow-Origin':'*'},
dataType: 'jsonp',
contentType: "application/json",
success: function(data){
console.log("Success"+data);
},
error: function(data){
debugger;
console.log("error "+data);
},
failure: function(data){
console.log("Failure"+data);
}
});
}
在 Spring Web 应用程序端调试:响应正在传递。
我尝试在 PHP 应用程序上使用相同的 API,并成功获取。但由于限制,我不能使用 jQuery 以外的其他东西。
控制台输出:
解决方案
推荐阅读
- linux - ImageMagick 没有解码委托
- mysql - SQL 查询没有值
- telegram - 用电报机器人显示表格?
- sql - 如何在 SAP HANA 1.2v 中实现层次结构或递归 CTE
- c# - 并行发出多个请求时,HttpClient 花费过多的时间(除非 Http 版本设置为 1.0)
- python - 正则表达式:如何检查 Python 中是否有任何进程占用了 80% 或更多的 CPU
- android - 为 android 构建变体使用不同的类
- java - Java 反射 - 检查可从类元数据分配
- angular - “值”应该是 Kendo Angular DatePicker 中的有效 JavaScript Date 实例
- dotnetnuke - DNN CMS 登录问题