2014-02-13 56 views
9

正如我们所知,我们可以使用X-Requested-With http请求头来判断一个http请求是否来自Ajax。X请求的HTTP请求头何处来自

很多JavaScript框架会自动添加在他们的Ajax请求X-Requested-With头,如jQuery AjaxPrototype Ajax。而作为List of HTTP header fields维基说X-Requested-With非标准的请求头

谷歌很多次后,我还没有找到谁首先想出X-Requested-With请求标题。

所以我想知道是否有人知道X-Requested-With从哪里来?谢谢...

回答

6

参考原型支持X-Requested-With可以在Should there be a standard X-Ajax-Engine request header?(posted 6/30/2006)中找到。

引用在Github上的jQuery源代码库到2006年5月16日的版本ajax.js,其中X-Requested-With最初被添加。

道场并没有看到添加,直到02/09/08和引用其他库:

jQuery的,原型,YUI和 - 因为它似乎 - Mootools的发送标题 “X-请求 - 由于:XMLHttpRequest的“用他们的XHR。

通过2008-10-21 v1.4,MochiKit调用此标准:

MochiKit.Async现在设置 “X-请求-随着:XMLHttpRequest的” 报头, 事实上的标准(原型,jQuery的,Mootools的) 。