JS利用XMLHttpRequest拦截ajax请求
2024-09-02 10:25:15
function XMLHttpRequestBreak(fun=()=>false){
let f = XMLHttpRequest.prototype.open; let add = function(){
XMLHttpRequest.prototype.open = function(...args){
check = fun(args);
if(check){
throw check;
}
f.apply(this,args)
}
}; let remove = function(){
XMLHttpRequest.prototype.open = f
}; return {add, remove}
} test = XMLHttpRequestBreak();
test.add()
test.remove() test = XMLHttpRequestBreak(()=>"123");
test.add()
test.remove() test = XMLHttpRequestBreak(console.log);
test.add()
test.remove()
最新文章
- python3--删除所有空目录,第一个有实际用处的程序
- Gobblin采集kafka数据
- IOS第一天
- 新浪微博客户端(32)-设置相册图片的contentMode
- SpringUtil
- jquery自适应布局
- 统计字符 比如aaabbcca----3a2b1c1a
- c# in depth之泛型的实现
- HDU 4791 &;amp; ZOJ 3726 Alice&;#39;s Print Service (数学 打表)
- 【Android Developers Training】 89. 最大化的使用谷歌云消息(Google Cloud Messaging)
- centos7防火墙导致不能访问的
- linux添加本地yum源
- Python内置的服务器的使用
- 吉哥系列故事――恨7不成妻 HDU - 4507 数位dp
- SNF快速开发平台--多组织+多平台+多系统处理方案
- 仿迅雷播放器教程 -- 基于VLC的MFC播放器 (6)
- MySQL Binlog和Relaylog生成和清理
- 13个开源GIS软件 你了解几个?
- wxWidgets与其他工具库的比较(上)
- 查看当前mysql数据库实例中,支持的字符集有哪些,或者是否支持某个特定字符集
热门文章
- [转载]C++STL概述
- Vue开发——实现吸顶效果
- 多个类用@feignclient标注同一个服务,出错问题:Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.Caused by: org.springframework.beans.factory.support.Bea..
- 忘记oracle的sys用户密码如何修改以及Oracle 11g 默认用户名和密码
- mysoft
- Shell脚本之sed详解
- Python、mysql四-1:单表查询
- PHP强制修改返回的状态码
- 关于order_by
- Java定时任务的几种方法(Thread 和 Timer,线程池)