欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

如何從jQuery的ajax請(qǐng)求中刪除X-Requested-With

 更新時(shí)間:2013年12月11日 17:48:21   作者:  
X-Requested-With常用于判斷是不是ajax請(qǐng)求,ajax請(qǐng)求中刪除X-Requested-With的方法如下,感興趣的朋友可以參考下
X-Requested-With常用于判斷是不是ajax請(qǐng)求

但是有時(shí)我們會(huì)有需要?jiǎng)h除X-Requested-With的情況

下面介紹一種方式 js代碼
復(fù)制代碼 代碼如下:

$.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請(qǐng)求的方式 java代碼
復(fù)制代碼 代碼如下:

if (request.getHeader("x-requested-with") != null
&& request.getHeader("x-requested-with").equalsIgnoreCase("XMLHttpRequest")) {
//異步請(qǐng)求
}else{

}

相關(guān)文章

最新評(píng)論