How does jquery achieve cross-domain access? Connect to other people's interfaces

Source: Internet
Author: User
Tags domain server

  • The following example you can refer to the following

    <script>

    $.ajax ({

    Async:false,

    URL: ' http://www.mysite.com/demo.do ',//cross-domain URL

    Type: ' GET ',

    DataType: ' Jsonp ',

    JSONP: ' Jsoncallback ',//default callback

    Data:mydata,

    timeout:5000,

    Beforesend:function () {//jsonp mode This method is not triggered. The reason may be that datatype, if specified as Jsonp, is not an AJAX event.

    },

    Success:function (JSON) {//client jquery pre-defined callback function, after successfully acquiring JSON data on a cross-domain server, this callback function is executed dynamically

    if (json.actionerrors.length!=0) {

    alert (json.actionerrors);

    }

    Gendynamiccontent (Qsdata,type,json);

    },

    Complete:function (XMLHttpRequest, Textstatus) {

    $.unblockui ({fadeout:10});

    },

    Error:function (XHR) {

    Jsonp mode This method is not triggered

    Request Error Handling

    Alert ("Request error (Please check correlation network status.)");

    }

    });

    Attention:

    $.getjson ("http://www.mysite.com/demo.do?name1=" +value1+ "&callback=?",

    function (JSON) {

    if (JSON. property name = = value) {

    Execute code

    }

    });

    </script>

How does jquery achieve cross-domain access? Connect to an interface provided by someone else

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.