In most cases, JavaScript-based Js frameworks such as jquery, Mootools, Prototype, etc., when issuing Ajax request instructions, will send additional HTTP_X_REQUESTED_WITH header information, as if it is an ajax request, so you can The server detects these Ajax requests. The detection method in PHP is as shown in the following code:
1
2if(!emptyempty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) =='xmlhttprequest'){
3 //This is your ajax request processing logic
4}else{
5 //Some logic. . .
6}
7?>
Used when developing Ajax interactive applications.