angularjs的$http获取到的json数据为什么在页面上显示不出来?
angularjs的$http获取到的json数据使用模拟环境(xampp)通过127.0.0.1访问没有问题,但是上传到新浪云为什么在页面上就显示不出来?就大神帮忙解决...
angularjs的$http获取到的json数据使用模拟环境(xampp)通过127.0.0.1访问没有问题,但是上传到新浪云为什么在页面上就显示不出来?就大神帮忙解决,感激不尽
angularjs代码:
$http
.get('data/head.php')
.success(function(data){
//console.log(data);
$scope.dishList=data;
});
//console.log(data)输出的数据:
[
{"nid":"1","nname":"\u5e97\u957f\u63a8\u8350"},
{"nid":"2","nname":"\u70ed\u9500\u4ea7\u54c1"},
{"nid":"3","nname":"\u5355\u53cd\u77e5\u8bc6"},
{"nid":"5","nname":"\u62db\u5546\u52a0\u76df"}
]
php代码:
<?php
header("content-type:application/json;charset=utf-8");
require('init.php');
$sql="select * from sin_nav";
$result=mysqli_query($conn,$sql);
$row=mysqli_fetch_all($result,MYSQLI_ASSOC);
echo json_encode($row);
?>
错误提示:Error: JSON.parse: unexpected character at line 1 column 1 of the JSON data 展开
angularjs代码:
$http
.get('data/head.php')
.success(function(data){
//console.log(data);
$scope.dishList=data;
});
//console.log(data)输出的数据:
[
{"nid":"1","nname":"\u5e97\u957f\u63a8\u8350"},
{"nid":"2","nname":"\u70ed\u9500\u4ea7\u54c1"},
{"nid":"3","nname":"\u5355\u53cd\u77e5\u8bc6"},
{"nid":"5","nname":"\u62db\u5546\u52a0\u76df"}
]
php代码:
<?php
header("content-type:application/json;charset=utf-8");
require('init.php');
$sql="select * from sin_nav";
$result=mysqli_query($conn,$sql);
$row=mysqli_fetch_all($result,MYSQLI_ASSOC);
echo json_encode($row);
?>
错误提示:Error: JSON.parse: unexpected character at line 1 column 1 of the JSON data 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询