JQuery plug-in jQuery-JSONP development ajax call precautions _ jquery

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.