问题
In Zend Framework and other framework such as Symfony, there is a method named isXMLHttpRequest() to determine this is XMLHttpRequest or not. I wonder that how can framework or PHP distinguish between XmlHttpRequest and HttpRequest?
if($this->_request->isXmlHttpRequest())
{
//code here
}
回答1:
From the documentation:
Zend_Controller_Request_Http has a rudimentary method for detecting AJAX requests: isXmlHttpRequest(). This method looks for an HTTP request header X-Requested-With with the value 'XMLHttpRequest'; if found, it returns TRUE.
来源:https://stackoverflow.com/questions/8499062/what-are-differences-between-xmlhttprequest-and-httprequest