In principle, I had a need to create a javascript APP object that would queue a sequence of asynchronous requests for the server, process the JSON response, and register errors from it.
JSON processing errors were easily fixed using try-catch, but server errors such as 404, 500, etc., still appear in the browser console, while I need to write it quietly in APP.history "
I tried to implement it using the code below, but none of the 404 errors worked. What am I doing wrong?
xhr = new XMLHttpRequest(); xhr.open("GET", url, true) xhr.onerror = function(){console.log("error")} xhr.upload.onerror = function(){console.log("error")}
By the way, how can this be done using jQuery AJAX?
source share