What are differences between XMLHttpRequest and HttpRequest

久未见 提交于 2019-12-13 00:12:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!