Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当页面被 ajax 加载时,我想返回一个稍微不同的页面。我可以将 jQuery 设置为自动附加一个查询字符串参数,我可以在服务器上使用该参数来检查页面是否由 ajax 加载?或者我是否必须手动向我的链接添加参数?还是有其他方法?
ajax 调用生成的 HTTP 请求通常应具有以下标头:
X-Requested-With:XMLHttpRequest
jQuery 和其他表现良好的库通常会在进行 ajax 调用时自动设置此标头。