如何从jQuery的ajax请求中删除X-Requested-With
2018-10-12 14:03
465 查看
X-Requested-With常用于判断是不是ajax请求
但是有时我们会有需要删除X-Requested-With的情况
下面介绍一种方式 js代码
附,判断ajax请求的方式 java代码
但是有时我们会有需要删除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{
}
您可能感兴趣的文章:
相关文章推荐
- 如何从jQuery的ajax请求中删除X-Requested-With
- 从jQuery的ajax请求中删除X-Requested-With
- 教你如何终止JQUERY的$.AJAX请求
- 利用x-requested-with判断请求是否是Ajax请求
- x-requested-with请求头与Ajax
- AJAX 请求区分 $_SERVER['HTTP_X_REQUESTED_WITH'] 小解
- 利用x-requested-with判断请求是否是Ajax请求
- PHP判断ajax请求:HTTP_X_REQUESTED_WITH
- x-requested-with 请求头 区分ajax请求还是普通请求
- x-requested-with 请求头 区分ajax请求还是普通请求
- 如何终止jquery的$.ajax请求
- PHP判断ajax请求:HTTP_X_REQUESTED_WITH
- x-requested-with 请求头 区分ajax请求还是普通请求
- Ajax 请求的http头信息特点 x-requested-with
- 如何通过禁用按钮避免jQuery.ajax重复请求
- 教你如何终止JQUERY的$.AJAX请求
- PHP判断ajax请求:HTTP_X_REQUESTED_WITH
- jquery如何停止ajax请求
- PHP判断ajax请求:HTTP_X_REQUESTED_WITH
- [jquery]AJAX 重定向的困境,如何重定向 URL 或如何设置重定向请求的属性