Why does jQuery tie their ajax request object to a window?

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();

Answers


Because the XMLHttpRequest object is a child of the window object.

You can reference it as a lone object since window is 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. Using window.XMLHttpObject prevents all the look ups by telling the browser exactly where to find it.


Need Your Help

Is this working properly - Sum of Fibonacci in Python 3

python numbers sum fibonacci

I have a task to make a program that will sum the first 100 Fibonacci numbers. I checked my output in Python, and my output in QBasic 64 and they aren't same. I checked with different inputs also.

How do I check out an SVN project into Eclipse as a Java project?

java eclipse svn ant subversive

I was trying to check out a project from SVN using Eclipse. I tried using "Checkout As" to make it into a "Java project from existing Ant script", but the project wizard requires the file to have a...