Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

xmlhttprequest error handling

const xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
       console.log( xhttp.responseText );
    }
};
// Error Handling:
xhttp.onerror = function(error){
	console.error( error );
}
xhttp.open("GET", "filename", true);
xhttp.send();
Comment

how to handle errors with xmlhttprequest

xhr.onerror = function (e) {
  console.error("Unknown Error Occured. Server response not received.");
};
Comment

PREVIOUS NEXT
Code Example
Javascript :: get last item in array javascript 
Javascript :: useeffect skip first render 
Javascript :: js generate random numbers 
Javascript :: return more than 1 value from function js 
Javascript :: how to create a form without a submit button javascript 
Javascript :: random numbers javascript 
Javascript :: nesting in react js 
Javascript :: js enum 
Javascript :: how to install formik in react native 
Javascript :: javascript check if dom element 
Javascript :: how to check all elements in array includes in another array javascript 
Javascript :: rror: btoa is not defined 
Javascript :: count word and space in text javascript 
Javascript :: rounding up a number so that it is divisible by 5 javascript 
Javascript :: js order string 
Javascript :: javascript class access static property 
Javascript :: list all functions in an object js 
Javascript :: chartjs Uncaught ReferenceError: Utils is not defined 
Javascript :: javascript break with for Loop 
Javascript :: class and id in react 
Javascript :: crear proyecto angular 
Javascript :: javascript if a variable is undefined 
Javascript :: detect a click outside an element javascript 
Javascript :: jqiery check if scroll to end 
Javascript :: react js multiple import 
Javascript :: js loop array in array 
Javascript :: scroll to top javascript 
Javascript :: javascript toPrecision() Method 
Javascript :: react conditionally disable button 
Javascript :: how to get which key is pressed in javascript 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =