zoukankan      html  css  js  c++  java
  • 温故而知新 监听 XMLHttpRequest 发起请求

    window.XMLHttpRequest.prototype.open 可以监听 XMLHttpRequest 。但不能监听fetch请求。

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!-- jquery -->
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    </head>
    
    <body>
    </body>
    <script>
    var _open = window.XMLHttpRequest.prototype.open
    var _send = window.XMLHttpRequest.prototype.send
    
    // https://github.com/Tencent/vConsole/blob/dev/src/network/network.js#L271
    window.XMLHttpRequest.prototype.open = function() {
        console.log(20181117200649, arguments)
        return _open.apply(this, arguments)
    }
    
    // fetch("http://localhost/fuck.php").then(response => {
    //     // console.log(20181117201438, response.json())
    //     return response.json()
    // }).then(data=>{
    //     console.log(20181117201450, data)
    // })
    
    $.ajax({
        url: "http://localhost/fuck.php",
        success: function (data) {
            console.log(20181117133228, data);
        }
    })
    </script>
    </html>
    

  • 相关阅读:
    BootStrap2学习日记15----选项卡
    BootStrap2学习日记14----导航
    Google地图下载工具代码
    SqlServer 动态SQL(存储过程)中Like 传入参数无正确返回值的问题
    地球坐标-火星坐标-百度坐标及之间的转换算法 C#
    GIS基础知识
    Gps坐标有效性判定
    Gps坐标距离计算C#实现
    C# 对字段忽略模型校验
    SQL基础复习2
  • 原文地址:https://www.cnblogs.com/CyLee/p/9977143.html
Copyright © 2011-2022 走看看