I’m using jQuery’s $.when() to handle multiple $.get() requests. This is how I have it set up.
var request1 = $.get('myURL');
var request2 = $.get('mySecondURL');
$.when(request1, request2).done(go);
function go(request1, request2){
console.log(request1);
console.log(request2);
}
Everything works great. Chrome’s console shows
[#document, "success", Object]
I know that #document is what I need to read, but what is the syntax to get it? Every example I’ve seen uses anonymous functions, which I’m not use to and bug me, coming from OOP AS3.
I’ve tried console.log(request1[0]); which works, but there has to be a more proper way. Something like request1.data or $(request1).$('#document');
Like I said, I’m a heavy Flex developer coming into JS and jQuery so the syntax I’m still trying to pickup.
According to the documentation for
$.when,request1[2]has thejqXHRobject, which in turn hasresponseTextmember. If you useconsole.login Chrome at least, you can see the contents of thejqXHRto find what member you specifically want to access, but it’s probablyresponseText.