<!DOCTYPE?html>
<html?ng-app="demo2">
<head>
????<meta?charset="UTF-8">
????<title>表格</title>
????<script?src="js/angular.js"></script>
????<script?src="js/biaogeTest.js"></script>
</head>
<body>
????<div?ng-controller="customersCtrl">
????????<table>
????????????<tr?ng-repeat="x?in?names">
????????????????<td>{{?x.Name?}}</td>
????????????????<td>{{?x.Country?}}</td>
????????????</tr>
????????</table>
????</div>
</body>
</html>/**
?*?Created?by?tongwii?on?2017/7/4.
?*/
var?app?=?angular.module('demo2',[]);
app.controller('customersCtrl',function?($scope,$http)?{
????$http.get("http://www.runoob.com/try/angularjs/data/Customers_JSON.php")
????????.then(function?(result)?{
????????????$scope.names?=?result.data.records;
????????});
});錯誤信息biaogeTest.html:1?XMLHttpRequest?cannot?load?http://www.runoob.com/try/angularjs/data/Customers_JSON.php.?
No?'Access-Control-Allow-Origin'
?header?is?present?on?the?requested?resource.?Origin?'http://localhost:63342'?
is?therefore?not?allowed?access.
angular.js:14525?Possibly?unhandled?rejection:?{"data":null,"status":-1,"config":{"method":"GET",
"transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback",
"url":"?
"headers":{"Accept":"application/json,?text/plain,?*/*"}},"statusText":""}
(anonymous)?@?angular.js:14525在網(wǎng)上查是說ajax跨域,請問這個如何解決?
請問使用angular中的$http報錯是為什么
呆呆呆
2017-07-04 10:15:35