Angularjs $ http get方法获取不带CALLBACK参数的JSONP数据 [英] Angularjs $http get method for JSONP data without CALLBACK parameter
本文介绍了Angularjs $ http get方法获取不带CALLBACK参数的JSONP数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通过在表中打印服务器上的某些JSON,我遇到了问题. 这是我的JSON
I have problem by printing in the table, some JSON that is on the server. This is my JSON
process([
{
"name": "A",
"value": "41"
},
{
"name": "B",
"value": "71"
},
{
"name": "C",
"value": "20"
}],"2017.07.11 15:48:33");
我的控制器:
myApp.controller('liveTable', function ($scope, $http) {
$http.get('http://something.com/get.php?jsonp=2017')
.then(function (response) {
$scope.myData= response.data;
console.log(response.data);
});
这是我的HTML
<div class="liveTable" ng-controller="liveTable">
<table>
<tr ng-repeat="item in myData.process">
<td>{{item.name}}</td>
<td>{{item.value}}</td>
</tr>
</table>
</div>
知道我哪里错了吗? tnx
Have any idea where I'm wrong? tnx
推荐答案
我认为您的json数据有问题.
I think there is something wrong with your json data.
我可以通过更改json数据来查看.您可以看一下.
i can see by changing you json data. you can have a look on it.
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-route.js"></script>
<body>
<div ng-app="myapp">
<div class="liveTable" ng-controller="myctrl">
<table>
<tr ng-repeat="item in process">
<td>{{item.name}}</td>
<td>{{item.value}}</td>
</tr>
</table>
</div>
</div>
</div>
<script>
angular.module("myapp",[]).controller("myctrl", function($scope){
$scope.process = ([
{
"name": "A",
"value": "41"
},
{
"name": "B",
"value": "71"
},
{
"name": "C",
"value": "20"
}]);
});
</script>
</body>
</html>
这篇关于Angularjs $ http get方法获取不带CALLBACK参数的JSONP数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文