How to return from closure without returning from contained function?
In the following function, the statement returnactually returns from GM_xmlhttpRequest: not closing. Naturally, I can see that I could arrange my code so that this execution shifts from the end of the close, but I'm curious how to return to the previous example.
function GM_xmlhttpRequest(details, callback) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState != 4)
return;
if (xhr.status != 200)
callback(null);
callback(xhr);
}
xhr.open('GET', details.url, true);
xhr.send();
};
source
share