XMLHttpRequest和HttpRequest有什么区别 [英] What are differences between XMLHttpRequest and HttpRequest

查看:77
本文介绍了XMLHttpRequest和HttpRequest有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Zend框架和其他框架(例如Symfony)中,有一个名为isXMLHttpRequest()的方法来确定是否为XMLHttpRequest.我不知道框架或PHP如何区分XmlHttpRequest和HttpRequest?

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
}

推荐答案

来自

Zend_Controller_Request_Http具有用于检测AJAX请求的基本方法:isXmlHttpRequest().这个方法寻找一个HTTP请求标头X-Requested-With,其值为'XMLHttpRequest'.如果找到,则返回TRUE.

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.

这篇关于XMLHttpRequest和HttpRequest有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆