jQuery or Ajax Error Post it

jQuery or Ajax Error Post it

I have an example for posting window.error. I would like to post .ajaxerror like the example below to my logger page/script. I am not sure how to do it.


WINDOW ERROR:
  1.  window.onerror = function (message, url, linenumber) {
  2.                
  3.                   if (window.XMLHttpRequest) {
  4.                       var xhr = new XMLHttpRequest();
  5.                       var scripturl = "Logger";
  6.                       var log = "?message=" + " LINE NUMBER: " + linenumber + " MESSAGE: " + message + " LOCATION:  " + url + " CLIENT BROWSER INFO:  " + window.navigator.userAgent;

  7.                       xhr.open("POST", scripturl + log); 
  8.                       xhr.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
  9.                       xhr.send(log);
  10.                       alert(scripturl + log);

  11.                   }
  12.                   return true;
  13.      }

AJAX ERROR: I would like to post .AjaxError like the example above to my logger page/script. I am not sure how to do it.
  1.  $(document).ajaxError( function (event, jqXHR, ajaxSettings, thrownError) {
  2.          alert('[event:' + event + '], [jqXHR:' + jqXHR + '], [ajaxSettings:' + ajaxSettings + '], [thrownError:' + thrownError + '])');

  3.         
  4.      });