Intercept outgoing browser HTTP requests

2019-08-10 02:36发布

问题:

I have a web application. Is it possible for my app to monitor all outgoing client browser HTTP requests that originate from my app? If it is, is it possible to intercept them and cancel them at will? Is there a JQuery HTTP interceptor, in particular?

回答1:

This is possible with JQuery using ajaxSetup.beforeSend

$.ajaxSetup({
  beforeSend: function(xhr) {
      //do your stuff here
  }
});