Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Set timeouts to XMLHttpRequests in javascript

let xhr = new XMLHttpRequest (); 
xhr.onreadystatechange = function () {  
    if (this.readyState == 4) {  
        clearTimeout(timeout);  
        // do something with response data 
    }  
}  
let timeout = setTimeout( function () {  
    xhr.abort(); // call error callback  
}, 60*1000 /* timeout after a minute */ ); 
xhr.open('GET', url, true);  

xhr.send();
Comment

PREVIOUS NEXT
Code Example
Javascript :: js-cookie set expiration of cookie 
Javascript :: package json scripts multiple commands 
Javascript :: create array javascript 
Javascript :: react history.push 
Javascript :: add scss in next js 
Javascript :: adding numbers in an array javascript 
Javascript :: cors express tutorial 
Javascript :: addclass javascript 
Javascript :: save form data jquery 
Javascript :: deprecation warning: value provided is not in a recognized rfc2822 or iso format. moment construction falls back to js date(), which is not reliable across all browsers and versions 
Javascript :: javascript get sum array values 
Javascript :: import all from javascript 
Javascript :: nesting in react js 
Javascript :: javascript vue.js right click 
Javascript :: get first 2 digits of number javascript 
Javascript :: javascript credit card validation 
Javascript :: react background image opacity 
Javascript :: passing state in link react 
Javascript :: js print all prime numbers 
Javascript :: javascript set query parameter 
Javascript :: javascript compare number to string 
Javascript :: js set css variable 
Javascript :: Looping through LI elements in UL 
Javascript :: embed example discord.js 
Javascript :: how to check how many strings are in a sentence javascript 
Javascript :: javascript check if variable is a jquery object 
Javascript :: iterate over map in javascript 
Javascript :: js Date(date).toLocaleString() MINUUTES 
Javascript :: js pass object property as a function parameter 
Javascript :: nodejs javascript heap out of memory 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =