0
我是phonegap应用程序开发的新手。我想创建一个应用程序,将与服务器进行通信(CRUD操作)。我用php创建了一个json。现在我想用angularJS来访问这个文件。但不能从服务器访问该文件(“http://apptest.byethost5.com/view.php”)。但是localhost给了我正确的结果。我认为那个文件有一些权限问题。我已将文件权限更改为755,但这不起作用。你能否建议正确的方法来处理这个问题。使用AngularJS无法从服务器访问文件
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="customersCtrl">
<table>
<tr ng-repeat="x in names">
<td>{{ x.firstname }}</td>
<td>{{ x.lastname }}</td>
</tr>
</table>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
$http.get("http://apptest.byethost5.com/view.php")
.then(function (response) {$scope.names = response.data.records;});
});
</script>
</body>
如果您不想允许来自任何域的请求,请确保将上面的*替换为您的特定请求域。 –