if ($_SERVER['HTTP_REFERER'] == "????")
如果JQuery $ .post请求到达此页面,HTTP_REFERER
会是什么?
答案 0 :(得分:4)
尝试
strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
注意并非所有服务器都提供此变量
你可以读到这个 Detecting Ajax in PHP and making sure request was from my own website