It's not a secret anymore!
The moose likes HTML, CSS and JavaScript and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "" Watch "" New topic

steve claflin
Ranch Hand

Joined: Dec 04, 2008
Posts: 54
I see a lot of online code using this structure, most notably in references to Ajax in Action, in particular; things like: While I understand how call works, what I can't figure out is why it is needed in this situation.

The code in my subject line seems to me to be exactly the same in effect as:
It would make sense to me if it were:
Am I missing something here?
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63534

From what you've posted, the need for call() in this case is unnecessary. It's not wrong, just unnecessarily wordy.

[Asking smart questions] [About Bear] [Books by Bear]
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
Trying to remember the exact code since I do not have it in front of me, but I think it is actually needed in that situation since this.onerror can be set in a different scope since it can be a reference to an outside method. It has been awhile since I looked at Dave's Ajax stuff.


I agree. Here's the link:
It's not a secret anymore!