How to make a jsonp request

前端 未结 2 1291
有刺的猬
有刺的猬 2020-11-28 10:47

I need to do some cross site scripting. The block of code below contains the method of jsonp, the method returns as if it failed, but when I change it to be a get request I

2条回答
  •  孤独总比滥情好
    2020-11-28 11:29

    If you want to make several JSONP requests through $http service, you should use a little hack. Agular change JSON_CALLBACK to internal value, and best way to use next solution: put this js code into your returned js-file:

    var callbackId = '_' + (angular.callbacks.counter - 1).toString(36);
    angular.callbacks[callbackId](/* YOUR JSON */);
    

    To be sure that this code will work for you, please check createHttpBackend method in angular sources.

提交回复
热议问题