Detect ajax requests from raw HTML

前端 未结 1 1146
臣服心动
臣服心动 2020-12-22 03:26

If you get a page\'s initial HTML, can you detect subsequent ajax requests?

Much like you can in the Developer Console, but programmatically. Have searched extensiv

相关标签:
1条回答
  • 2020-12-22 03:52

    You can use PerformanceObserver with entryType set to "resource"

    function perf_observer(list, observer) { 
       // Process the "resource" event 
    } 
    var observer2 = new PerformanceObserver(perf_observer); 
    observer2.observe({entryTypes: ["resource"]});
    

    See

    • Count console.log objects

    • Handling <?xml-stylesheet> similar to <link rel="stylesheet">?

    0 讨论(0)
提交回复
热议问题