javascript - angular 1.5 jsonp code call is not hitting the success method -
my jsonp code not working using angular reason! i've read thousands of examples doesn't work. see code below.
i've read question , hasn't resolved problem angularjs jsonp not working
my example code shows http.jsonp call success , error methods defined. i'm using chrome develop , test moment , second , third images show ajax service call , jsonp response service.
latest update
after receiving @thesharpieone server response returning actual function (instead of string problem previously) success method not executed reason?
$http.jsonp(url).then(function(response) { alert('success'); // not hit }, function onerror(response) { alert('error'); // displayed });
many thanks,
angular js
var url = serviceroot + "api/customer/get?callback=json_callback"; $http.jsonp(url).success(function (data) { alert('success'); // never called }) .error(function () { alert('error'); });
chrome network panel
shows chrome network panel, highlighting ajax call
ajax response
your jsonp response quoted, shouldn't be. supposed execute script, call callback function. right string, not javascript function call parameters.
jsonp works dropping new <script>
tag on page linking url. when executes, supposed call callback. thus, jsonp's response should javascript , not string.
Comments
Post a Comment