Home >Web Front-end >JS Tutorial >jQuery plug-in jQuery-JSONP development ajax call usage precautions_jquery

jQuery plug-in jQuery-JSONP development ajax call usage precautions_jquery

WBOY
WBOYOriginal
2016-05-16 17:13:061180browse

JSONP call sample code:

Copy code 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 pay attention to is the callbackParameter. If there is no special callback function, be sure to write "callback";

The second thing to pay attention to is in the success callback function, directly through The variable name originImgSrc is undefined and needs to be obtained through xOptions.data.imgSrc.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn