I have seen that many people are reluctant to face up to the technical bottlenecks of ajax. In fact, AJAX should be more Ajax than AJAX, highlight first A: I want to emphasize that AJAX is actually A method of asynchronous transmission, rather than the specific technology used since the birth of AJAX, the XMLHttprequest object does not support cross-origin requests. This seems to be a classic problem. This is caused by the same-source javascript policy (which is not discussed in depth here.
There are several solutions:
1. Intermediate Layer Transition (can be understood as "proxy "):
The intermediate transition, obviously, is to add a transitional layer between AJAX and servers in different domains for communication, this layer transition can be PHP, JSP, c ++, and other languages with network communication functions. The middle layer reads data to servers in different domains. Take asp.net as an example. If you need to communicate with an asp.net in different domains, the xmlhttprequest on the client first queries an asp.net in the current domain, then, the asp.net in the current domain will communicate with asp.net in different domains, and then the asp.net response output (response) in the current domain will be like this, I believe that the reader has clearly understood it.
2. Use the <script> label
This method uses the src in the <script> tag to query An aspx to obtain the response, because the src attribute of the <script> tag does not have a cross-origin issue.
Let's take a look at the following example:
The Code is as follows:
Cross-origin Ajax Problems