View Single Post
Old 02-01-2012, 01:11 AM   PM User | #2
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,530
Thanks: 0
Thanked 503 Times in 494 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
You have:

Code:
xhr.onreadystatechange = setWord();
which runs setWord are attaches whatever is returned to be run whenever the readyState changes. At this point it is 0 which is not equal to 4.

You don't return anything from the setWord function and so there is nothing to actually run when the state does change to 1, 2, 3 and eventually 4.

To get setWord to run when the state changes you need to change that line to read:

Code:
xhr.onreadystatechange = setWord;
That way the function will not run now and will instead run when the state changes.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote