When cross-domain, the JS Ajax request appears in the options request

Source: Internet
Author: User

The article above says HTTP options. It's been a long time. I tried many versions of jquery, and the following code was not a problem to test on a colleague's machine. The normal request, one on my machine will appear on the option, Online said first to the server pre-check and so on. Why is it normal to work on a colleague's machine? Finally find out why. is i in the HTML page also introduced a global JS file, which has a global configuration crossdomain:false, so I in the AJAX request is added Crossdomain:true, OK. Make its request a cross-domain request.

Postdata:function (t,i) {

var i=i| | 0;
var ad_type = 1;
var ad_pos = ';
var click_close = $ (". Pop_body"). attr ("Click_close"); Click on to close
if (t = = ' show ') Ad_type = 1;
if (t = = ' close ') Ad_type = 3;
if (t = = ' clicks ') {
Ad_type = 2;
Ad_pos = this.winoptions.type[' clicks '][i];
if (click_close) $.ydapp.client.hidepopwindow ();
}
if (Ad_type = = 3) {
$.ydapp.client.hidepopwindow ();
}
var closetips = function () {
if (Ad_type = = 3) $.ydapp.client.closepopwindow ();
if (Ad_type = = 2 && click_close) $.ydapp.client.closepopwindow ();
}
var post_data = {' Preview ': This.winOptions.is_preview,
' oem_id ': this.winOptions.oem_id,
' client_id ': this.winOptions.client_id,
' Client_ver ': This.winOptions.client_ver,
' tips_id ': this.winOptions.tips_id,
' Tips_name ': This.winOptions.tips_name,
' Ad_type ': Ad_type,
' Ad_pos ': Ad_pos
};


$.ajax ({
Type: ' POST ',
URL: $.ydapp.config.site_url+ "/ntips/ajaxcount",
Data:post_data,
DataType: ' Jsonp ',
Crossdomain:true,
JSONP: ' Jsoncallback ',
Success:closetips,
Error:closetips
});

},

Also, be aware that JSONP cross-domain requests are get methods and cannot upload files.

When cross-domain, the JS Ajax request appears in the options request

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.