为了账号安全,请及时绑定邮箱和手机立即绑定

请问使用angular中的$http报错是为什么

请问使用angular中的$http报错是为什么

呆呆呆 2017-07-04 10:15:35
<!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在网上查是说ajax跨域,请问这个如何解决?
查看完整描述

目前暂无任何回答

  • 0 回答
  • 1 关注
  • 4241 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信