Here are several solutions:
In the Ajax application environment, the browser does not allow the XMLHttpRequest component to request cross-origin resources for security reasons. In many cases, this restriction causes a lot of inconvenience. Many colleagues have studied various solutions:
1. modify document. domain and the hidden IFRAME to implement cross-origin requests. This scheme may be the simplest one for cross-origin requests, but it is also the most restrictive scheme. First, it can only implement cross-origin requests under the same top-level domain name. In addition, when another IFRAME is contained in a page, security exceptions may occur and access is denied.
2. By requesting the proxy of the current domain, the server proxy can access resources of another domain. XMLHttpRequest requests a server resource in the domain and provides the target resource to be accessed to the server. The server then acts as a proxy to access the target resource. This scheme can achieve full cross-origin access, but the consumption of the request process will be relatively large during development.
3. You can request cross-origin resource tag reference in HTML, such as image, script, and link tags. Among these tags, script is undoubtedly the most suitable. When requesting every script resource, the browser will parse and run the function defined in the script file, or the Javascript that needs to be executed immediatelyCode, We can use the server to return a script or JSON object, parse and execute in the browser, so as to achieve the purpose of cross-origin requests. Use the script tag to implement cross-origin requests. You can only use the get method to request server resources.
Original article: Cross-Domain Ajax request (extjs) implemented by using the script tag)