JQuery cross-origin problem solution _ jquery

Source: Internet
Author: User
When XMLHTTPRquest is used to request data in different domains, js cross-origin access originally had a function processing path "test" in the background. Next we will introduce jQuery's cross-domain problem solution. If you need it, you can refer to the next section to request data in different domains through XMLHTTPRquest, in the past, js cross-origin access was a function with a processing path "/test" in the background. The specific solution is described as follows.

Function of the backend processing path "/test:

The Code is as follows:


// Path Processing
App. get ("/test", user. test );
// Processing functions
Exports. test = function (req, res ){
Res. end ("alert ('js cross-origin access ')");
};

If there is a webpage that requires access to the content under the path "/test", you can use the JS script file for cross-origin access:

The Code is as follows:


// Processing functions
Script
Function method (data ){
Console. log (data );
}
Script
// Cross-origin access

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.