search

Home  >  Q&A  >  body text

angular.js - How can angular $http Jsonp handle the response of json data?

Code:
$http.jsonp("https://request.address.json)

.success(
    function(data, status, header, config){
        $scope.list = data;
        alert(data);
    }
)
.error(
    function(data){
        alert("error");
    }
);

Request response prompt:
Uncaught SyntaxError: Unexpected token:

But looking at the request through the browser, you can see that the returned data is json Data, not jsonp Data

Find out how to make angular cross-domain request json format data
(Don’t tell me about adding callback to the URL, that is a parameter used to process jsonp data)

漂亮男人漂亮男人2830 days ago647

reply all(5)I'll reply

  • 迷茫

    迷茫2017-05-15 16:59:27

    $http.get("xxxxx")

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-15 16:59:27

    jsonp requires the cooperation of the server. It should be that the server does not return the jsonp format

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-15 16:59:27

    The requested URL needs to add &callback=JSON_CALLBACK, which requires the server to cooperate with the format of returning jsonp. In this way, it can be obtained correctly in the early callback.

    reply
    0
  • 阿神

    阿神2017-05-15 16:59:27

    I can’t understand you return data. Isn’t the data node just data?

    reply
    0
  • PHP中文网

    PHP中文网2017-05-15 16:59:27

    Has it been resolved? Can you tell me if you have solved it? Thank you

    reply
    0
  • Cancelreply