码迷,mamicode.com
首页 > Web开发 > 详细

ajax如何删除X-Requested-With

时间:2016-01-09 11:02:02      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:

ajax如何删除X-Requested-With:
在实际应用中,X-Requested-With一般用来判断一个请求是否是ajax请求,不过有时候这个并不需要,所以要将其删除,下面就此就进行一下简单介绍,希望能够对需要的朋友带来或多或少的帮助。
解决方案如下:

 

$.ajax({ 
  url: ‘http://www.softwhy.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‘ ); 
    } 
  } 
});

 

原文地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=11006

更多内容可以参阅:http://www.softwhy.com/jquery/

 

ajax如何删除X-Requested-With

标签:

原文地址:http://www.cnblogs.com/zhengzebiaodashi/p/5115580.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!