In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "how to configure the server to achieve AJAX cross-domain request". In the daily operation, I believe many people have doubts about how to configure the server to achieve AJAX cross-domain request. The editor consulted all kinds of materials and sorted out a simple and useful method of operation. I hope it will be helpful to answer the doubt of "how to configure the server to achieve AJAX cross-domain request". Next, please follow the editor to study!
It has always been thought that AJAX cross-domain is an insurmountable gap. Recently, it was found that AJAX cross-domain requests can be allowed by sending header messages on the server.
PHP code example:
The copy code is as follows:
Header ('Access-Control-Allow-Origin:*')
Header ('Access-Control-Allow-Headers:X-Requested-With')
After testing, the browser of the webkit kernel successfully implements the cross-domain request.
IE does not support it as always. It seems that we can only enjoy this powerful feature on the mobile side.
In addition, it is important to note that the * in the first line configuration allows cross-domain requests from all referer, which can be configured as a specific domain name if you do not want to be fully open. This ensures that only cross-domain requests from specific domain names can succeed. For example:
The copy code is as follows:
Header ('Access-Control-Allow-Origin: http://www.test.com');
The meaning of the second line configuration is to allow an asynchronous AJAX request, because the asynchronous AJAX automatically sends this header message, and the server usually determines that it is an AJAX request by accepting the header message. Generally speaking, the AJAX requests we send are asynchronous.
At this point, the study on "how to configure the server to implement AJAX cross-domain requests" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.