如何从jQuery的ajax请求中删除X-Requested-With - Web前端
作者:98wpeu发布时间:2026-06-09分类:网页前端技术浏览:9
导读:X-Requested-With常用于判断是不是Ajax请求但是有时我们会有需要删除X-Requested-With的情况下面介绍一种方式JS代码复制代码代码如下:$.aj...
X-Requested-With常用于判断是不是Ajax请求
但是有时我们会有需要删除X-Requested-With的情况
下面介绍一种方式 JS代码
复制代码 代码如下:
$.ajax({
url: 'http://www.zhangrUIfeng.com',
beforeSend: function( xhr ) {
xhr.setRequestheader('X-Requested-With', {toString: function(){ return ''; }});
},
success: function( data ) {
if (console && console.log){
console.log( 'Got data without the X-Requested-With header' );
}
}
});
附,判断ajax请求的方式 java代码
复制代码 代码如下:
if (request.getHeader("x-requested-with") != null
&& request.getHeader("x-requested-with").equalsIgnoreCase("XMLHttpRequest")) {
//异步请求
}else{
}
但是有时我们会有需要删除X-Requested-With的情况
下面介绍一种方式 JS代码
复制代码 代码如下:
$.ajax({
url: 'http://www.zhangrUIfeng.com',
beforeSend: function( xhr ) {
xhr.setRequestheader('X-Requested-With', {toString: function(){ return ''; }});
},
success: function( data ) {
if (console && console.log){
console.log( 'Got data without the X-Requested-With header' );
}
}
});
附,判断ajax请求的方式 java代码
复制代码 代码如下:
if (request.getHeader("x-requested-with") != null
&& request.getHeader("x-requested-with").equalsIgnoreCase("XMLHttpRequest")) {
//异步请求
}else{
}
相关推荐
- 三种取消选中单选框radio的方法 - Web前端
- 理解jQuery stop()方法 - Web前端
- 分享2个jQuery插件--jquery.fileupload与artdialog - Web前端
- jquery引用方法时传递参数原理分析 - Web前端
- jQuery实现视频作为全屏幕背景 - Web前端
- 使用jQuery设置disabled属性与移除disabled属性 - Web前端
- jQuery判断当前点击的是第几个li的代码 - Web前端
- 一个支付页面DEMO附截图 - Web前端
- jquery实现的鼠标拖动排序Li或Table - Web前端
- jQuery实现复选框全选/取消全选/反选及获得选择的值 - Web前端
- 网页前端技术排行
- 最近发表
-
- WordPress随机显示特色图片插件:Random Post Thumbnails
- KeePass实现Chrome浏览器自动填充密码方法一
- LNMP一键包nginx 301强制跳转到https教程
- KeePass实现Chrome浏览器自动填充密码方法二
- #建站# 免费的VPS管理软件Xshell8/Xftp8中文版下载
- 使用Xshell 8连接VPS教程_电脑登录vps的方法
- WordPress评论界面添加烟花????效果
- 不同浏览器书签同步方案:坚果云+Floccus_详细使用教程
- iOS端KeePassXC客户端APP:Strongbox Password Safe
- 给WordPress评论中的Gravatar头像图片添加ALT属性


