Detect ajax requests from raw HTML

前端 未结 1 1161
臣服心动
臣服心动 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 similar to ?

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