Angular in PHP page read an API generated in php

Asked

Viewed 163 times

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>

http://www.w3schools.com/angular/tryit.asp?filename=try_ng_customers_mysql

I need to make this API read: http://folhacar.com.br/api/listAnuncios?revenda_id=528&cnpj=13733235000134

I have changed the fields to the relative fields and everything else but nothing gives read. I am rude erring somewhere?

1 answer

1

The main problem is that this data you are trying to access is not available via AJAX from another domain. The server of that site (flip) would need to be configured to allow access to cross-origin. For more details and a possible alternative, see How to make Ajax requests, with Jquery, in different domains?

I changed the fields to the relative fields and everything

Since you didn’t show your altered code, there’s no way to tell if there was a problem with that part either. But solving the first problem I pointed out, you soon find out :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.