wongadob Posted March 15, 2012 Share Posted March 15, 2012 Hi, I have a javascript object that has been pre-defined using a constructor function. One of the elements of the object is a success function. This success function is an ajax server get success call, but can be too different functions dependant on how it is set up. The line I know is wrong is the following, but I do not know how it should be set. ajaxfunc.success = updateCacheAndDisplay(feed); ajaxfunc is the objectsuccess should hold the function I wish to call on success updateCacheAndDisplay is the function that I want to be called on success.feed is the data I also want passed, although this is not essential just now. I could set ajaxfunc.data=feed or something similar and access it via this.data in the function (I think) So the main issue is how to I set ajaxfunc.success to point be the updateCacheAndDisplay function. Thanks PS Object & OOP & Javascript newbie so please be gentle. Link to comment Share on other sites More sharing options...
eTianbun Posted March 15, 2012 Share Posted March 15, 2012 ajaxfunc.success=updateCacheAndDisplay assign just the name of the function to success (without parenthesis), then call it like this: ajaxfunc.success('feed') Link to comment Share on other sites More sharing options...
wongadob Posted March 15, 2012 Author Share Posted March 15, 2012 Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.