(simple) AJAX question
Author
Discussion

zoidberg

Original Poster:

8,887 posts

313 months

Wednesday 17th January 2007
quotequote all
Simple but annoying me.

Why, when you tell the browser to wait for a response from the server, do you not include parentheses on the function name?

i.e:

request.onreadystatechange = updatePage;

Why isn't it:

request.onreadystatechange = updatePage();

??

Cheers.

dern

14,055 posts

310 months

Wednesday 17th January 2007
quotequote all
I don't know the answer in the context your talking about but I suspect that you're passing a reference to the method that will be called when the event occurs rather than passing the return value from the method IYSWIM.

beaker123

1,405 posts

242 months

Wednesday 17th January 2007
quotequote all
In simple language, you are simply stating that the reference for a is equal to the reference for b, thus making a and b one and the same.

If you included brackets, you would be saying that a is equal to the return value of b.

...if you see what I mean.

zoidberg

Original Poster:

8,887 posts

313 months

Thursday 18th January 2007
quotequote all
Thanks for the replies, makes sense.