2

How can i get the response value from the http onload function? I know it's something with a Asynchronous call!

httpRequest.onload = function() {
        var response = JSON.parse(this.responseText);
        test(response);
        /*....*/ 
};

exports.test = function(){
  return response;
};

Thanks in advance!

Papauha
  • 169
  • 1
  • 1
  • 8
  • have a look at https://developer.mozilla.org/en/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest for how to use this object. – Marvin Smit Apr 03 '15 at 07:44
  • Well, the thing with asynchronous calls is that you cannot. The callbacks return to nowhere! – Bergi Apr 03 '15 at 10:33
  • Please [edit] your question to describe the exact problem you're having and to make sure it's not a duplicate of [How to return the response from an ajax call?](http://stackoverflow.com/q/14220321/1048572) – Bergi Apr 03 '15 at 10:41

0 Answers0