码迷,mamicode.com
首页 > Web开发 > 详细

Ajax请求返回Error:200无数据的解决方法

时间:2019-03-05 16:58:11      阅读:612      评论:0      收藏:0      [点我收藏+]

标签:col   cti   解决   ***   ima   com   检查   ESS   img   

先看代码

 1 $.ajax({
 2         type:"GET",
 3         url:"https://****/charts/data/genre2.json",
 4         dataType:"json",
 5         success:function(data){
 6             if(data.errorCode==0){
 7                 console.log("成功,无数据");
 8                 console.log(data);
 9             }else{
10                 console.log(data);
11                 createChart(data);
12             }
13         },
14         error:function(jqXHR){
15             console.log("Error: "+jqXHR.status);
16         }
17     });

报错现象:页面为空

技术图片

解决方式:因为返回200表示请求成功,已返回网页;但是无数据,那么可以检查数据;

[
  {‘genre‘:‘Sports‘,‘sold‘: 275 },
  { ‘genre‘: ‘Strategy‘, ‘sold‘: 115 },
  { ‘genre‘: ‘Action‘, ‘sold‘: 120 },
  { ‘genre‘: ‘Shooter‘, ‘sold‘: 350 },
  { ‘genre‘: ‘Other‘, ‘sold‘: 150 }
]

如上,这是要请求的数据,将json内单引号改为双引号再测试即可;

参考博客:https://blog.csdn.net/java_zhangshuai/article/details/80274510

[
  {"genre":"Sports","sold": 275 },
  { "genre": "Strategy", "sold": 115 },
  { "genre": "Action", "sold": 120 },
  { "genre": "Shooter", "sold": 350 },
  { "genre": "Other", "sold": 150 }
]

技术图片

 

Ajax请求返回Error:200无数据的解决方法

标签:col   cti   解决   ***   ima   com   检查   ESS   img   

原文地址:https://www.cnblogs.com/chig/p/10477843.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!