javascript - Accessing jqXHR object properties from $.get request -


i have simple function looks this:

function geturl(url) {   return $.get(url); } 

which im calling (somewhere else, in unit test) such:

var url = geturl("/page/stuff")     console.log(url); 

so console.log(url) works, , returns statustext/status etc... should.

however, how can access properties of jqxhr object. instance url.status returns undefined.

is loading issue? whereas im logging before i've received page...if how come printing off url variable returns object?

how can access properties of jqxhr object. instance url.status returns undefined.

by accessing after request has completed:

var jqxhr = geturl("/page/stuff");  jqxhr.always(function (result) {     console.log(jqxhr.status); }); 

is loading issue? whereas im logging before i've received page...

yes.

if how come printing off url variable returns object?

because $.get() returns object represents request. of properties not populated until request completes.


Comments