Angularjs JSONP not working

前端 未结 3 1245
抹茶落季
抹茶落季 2020-11-29 03:12

I might be missing something here but I can\'t make this JSONP request work, here is the code:

var url =  \'http://\' + server + \'?callback=JSON_CALLBACK\';         


        
3条回答
  •  猫巷女王i
    2020-11-29 03:56

    If the response data is "pure" JSON, we can just handle it with angular's $http.get.

    $http.get(url).
      then(function(response) {
        // this callback will be called asynchronously
        // when the response is available
        $scope.responseArray = response.data;
     }, function(response) {
        // called asynchronously if an error occurs
        // or server returns response with an error status.
     });
    

    Refer to the example on w3schools

提交回复
热议问题