0
How Location Variable execute ?
var req = new XMLHttpRequest(); req.onload = reqListener; req.open('get','example.com/accountDetails',true); req.withCredentials = true; req.send(); function reqListener() { location='/log?key='+this.responseText; };
2 Antworten
+ 2
Do you mean the "location" variable in this function?
function reqListener() {
location='/log?key='+this.responseText;
};
If you do, it gets set when your request completes. That's because the reqListener() function is passed as the onload callback function when you set up your request:
request.onload = reqListener
+ 1
why did you have deleted your previous thread about same question?
anyway, by 'Location Variable' did you mean second argument of req.open() call?
if so, that's the url used to make the http request trough ajax...
if this is an absolute complete url (starting with protocol -- usually 'http' or 'https'), it is used as is.
if this is not, the url is build relatively to actual page url: at least prepennding the protocol, else using the domain name (if url start with '/') or at most computing the url relatively to page url...