Hi, The issue is that when the interval fires the call to checkForMessages, it doesn't give it the right "this" context, because JavaScript doesn't have *methods*, just functions (which is all it needs, but leads to issues like this). If you search in this group for "binding" you'll find several discussions of this issue.
You'll want to use Function.bind[1] when setting up the timed interval call of checkForMessages. For more information, here's[2] a link to a post on my blog about this sort of thing, and here's[3] an article on A List Apart by Christophe Porteneuve. [1] http://prototype.org/api/function/bind [2] http://blog.niftysnippets.org/2008/04/you-must-remember-this.html (on my neglected blog) [3] http://www.alistapart.com/articles/getoutbindingsituations This other post on my blog may also be of use; goes into more detail about methods vs. functions: http://blog.niftysnippets.org/2008/03/mythical-methods.html HTH, -- T.J. Crowder tj / crowder software / com On Oct 20, 7:10 am, Travis <[EMAIL PROTECTED]> wrote: > I am trying to implement the following: > > var Messaging = Class.create({ > initialize: function() { > setInterval(this.checkForMessages, 20000); > }, > checkForMessages: function(event) { > var options = { > method: 'get', > onSuccess: this.pushData.bind(this) > } > > new Ajax.Request('/messages/check', options); > }, > pushData: function(transport) { > alert(transport.responseText); > } > > }); > > Unfortunately, I get an error "this.pushData is null or not an > object". I think it's a binding issue but I'm not sure since I though > I had binded "this" to pushData. Any help would be great, thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---