首页
Profile
Profile
Profile
Profile
Profile

PHP检测 ajax 请求

2011-01-15 阅读 89
PHP检测 ajax 请求,大多数的 JavaScript 框架如 [jquery](http://paranimage.com/tag/jquery/),Mootools 等,在发出 Ajax 请求时,都会发送额外的 HTTP\_X\_REQUESTED\_WITH 头部信息,头当他们一个ajax请求,因此你可以在服务器端侦测到 Ajax 请求。
    if(!emptyempty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
        //If AJAX Request Then
    }else{
    //something else
    }
    ```


PHP 检测 ajax 请求



更新于 2023年03月28日
 
陕ICP备13008705号-1 Chat Gpt Api