JQuery-JSONP is a jQuery plug-in that supports JSONP calls. It is used because it supports ajax callback in case of errors, while jQuery's $. ajax is not supported. We have already used it in the actual project. We encountered two problems at the beginning. Here we will record and share them. Sample Code for calling JSONP:
The Code is as follows:
Var originImgSrc = 'cnbogs-logo.gif ';
$. Jsonp ({
Url :'',
Data: {imgSrc: originImgSrc },
CallbackParameter: "callback ",
Success: function (newImgSrc, textStatus, xOptions ){
Console. log (xOptions. data. imgSrc );
},
Error: function (xOptions, textStatus ){
}
});
The first thing to note is callbackParameter. If there is no special callback function, you must write "callback ";
Note that in the success callback function, the variable name originImgSrc directly gets undefined, which must be obtained through xOptions. data. imgSrc.