What are differences between XMLHttpRequest and Ht

2019-08-13 19:33发布

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条回答
Luminary・发光体
2楼-- · 2019-08-13 20:02

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.

查看更多
登录 后发表回答