In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you the AJAX request to distinguish between $_ SERVER ['HTTP_X_REQUESTED_WITH'] example analysis, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's learn about it!
Affected by a lot of template code, everyone thinks that php has such a custom variable: $_ SERVER ['HTTP_X_REQUESTED_WITH']. In fact, that is not the case at all.
$_ SERVER is an array containing information such as header information (header), path (path), and script location (script locations). These are the exact words of the PHP manual.
Some header information exists in the system itself and cannot be changed, such as HOST,USER_AGENT, etc. Note that we often use $_ SERVER ['HTTP_HOST'], $_ SERVER [' HTTP_USER_AGENT'], where there is a HTTP prefix. In implementation, there is no HTTP prefix in the header message, the name of the information is just HOST and so on, and $_ SERVER automatically prefixes them with HTTP. 1 is to prevent conflicts with other information, 2 is to indicate that they are header header information. So all variables in $_ SERVER with HTTP prefix are header information, and those without are not, such as $_ SERVER ['QUERY_STRING'], $_ SERVER [' PHP_SELF'] and so on.
The user can create custom header header information and send it to the server. The server will record the header information and store it in the $_ SERVER variable. Of course, the variable name of the implementation becomes the variable name of the user connected to "HTTP_". For example, the above judgment ajax request. In fact, before sending an asynchronous request to the server, a header message is added to the header. The actual statement should be:
HttpRequest object .setRequestHeader ("X_REQUESTED_WITH", "arbitrary string"); whether the variable $_ SERVER ['HTTP_X_REQUESTED_WITH'] exists on the server, or a specific value to determine whether it is an ajax request or which ajax request it is. So you can not only verify whether the request is an ajax request, but also get more information.
Similarly, we can set up any other information in header to communicate with the server.
For example, xmlHttpRequest.setRequestHeader ("test", "just a test"); then the value of the variable $_ SERVER ['HTTP_TEST'] in the requested server page is "just a test"; note that the test in front of it is not case-sensitive. The following $_ SERVER ['HTTP_TEST'] must be uppercase.
The above is all the content of the article "sample Analysis of AJAX request distinguishing $_ SERVER ['HTTP_X_REQUESTED_WITH']". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.