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