K
K
kootoo2016-11-03 13:35:20
JSON
kootoo, 2016-11-03 13:35:20

AngularJS and request via jsonp?

Good day.
Faced a problem.
There is access to the API of the form:
randomsite.ru/manufacturers?userlogin=USER_LOGIN&u...
Upon request, JSON is returned
Decided to process JSON using AngularJS

var app = angular.module('avtoz', []);
 var url = "http://randomsite.ru/manufacturers?userlogin=USER_LOGIN&userpsw=USER_PSW&userkey=USER_KEY";
 
  app.controller('modelsFn', function ($scope, $http){
    $http.jsonp(url + '&callback=JSON_CALLBACK').then(function(data) {
      $scope.models = data;
    });
  });

Since the usual get does not work on a cross-domain, I read a lot of information about jsonp.
But there is a problem, when substituting &callback=JSON_CALLBACK nothing happens.
It does not give any errors, it returns JSON, but JSON refuses to be parsed, although it can be seen through the chrome console that the data was loaded and the request was successful.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question