Why does JQuery ( latest source ) tie there Ajax Request Object to a window like this?
return new window.XMLHttpRequest();
I’m asking b.c. in my source I don’t do this.
I just do
return new XMLHttpRequest();
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Because the
XMLHttpRequestobject is a child of thewindowobject.You can reference it as a lone object since
windowis the parent scope in the browser; i.e. the global scope. If the reference isn’t in the local scope (closure), JavaScript keeps going up the scope chain until the reference found. Usingwindow.XMLHttpObjectprevents all the look ups by telling the browser exactly where to find it.