Angular in PHP page read an API generated in php

2

I'm talking about this example:

<div ng-app="myApp" ng-controller="customersCtrl">
<table>
  <tr ng-repeat="x in names">
    <td>{{ x.Name }}</td>
    <td>{{ x.Country }}</td>
  </tr>
</table>
</div>

<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
   $http.get("http://www.w3schools.com/angular/customers_mysql.php")
   .success(function (response) {$scope.names = response.records;});
});
</script>

link

I need to read this API: link

I changed the fields to relative fields and everything else but nothing makes reading. Am I rude erring somewhere?

    
asked by anonymous 07.07.2015 / 20:15

1 answer

1

The main problem is that the data you are trying to access is not available via AJAX from another domain. The server on that site (folhacar) would need to be configured to allow cross-origin access. For more details and a possible alternative, see #

  

I've changed fields to relative fields and everything else

Since you did not show your changed code, we can not say if there was any problem in that part either. But solving the first problem I pointed out, you soon discover:)

    
08.07.2015 / 05:26