Wow, thanks T.J.!! your answer makes a lot of sense.. but, now, how I am supposed to pass a function name instead of a string? I'm sorry if the question sounds stupid to you but I don't know how to achieve this target.
Thanks Omar On Mar 24, 12:55 pm, "T.J. Crowder" <[email protected]> wrote: > Hi, > > In this code: > > function click() { > var opt = { > method: 'get', > onCreate: 'create', > onLoading: 'loading', > onSuccess: 'sucess', > onException: 'error' > }; > var login = new jsTTALogin(URL, opt); > > } > > ...you're providing strings instead of functions. That's causing an > exception, which Prototype then tries to handle via `onException` -- > but `onException` is *also* a string, not a function. The error > message in Firefox+Firebug is wrong (interestingly). It's triggered > from line 1540 in Prototype.js: > > 1539 dispatchException: function(exception) { > 1540 (this.options.onException || Prototype.emptyFunction)(this, > exception); > 1541 Ajax.Responders.dispatch('onException', this, exception); > 1542 } > > ...which resolves to: > > "error"(this, exception) > > ...and of course, "error" is a string, not a function. > > So that's what's going wrong. It looks to me like you're trying to > pass the names of functions that exist in your subclass as options. > That's not how you reference functions, you need to provide a function > reference. > > Off-topic: I'm a bit surprised that `initTTA` in jsTTA.js works (but > it does seem to), it seems to me that it's trying to call `eval` on a > script element, which I would expect to have...undefined results. You > can (and probably should) drop that `eval` and it should work just > fine, more > here:http://proto-scripty.wikidot.com/prototype:how-to-load-scripts-dynami... > > HTH, > -- > T.J. Crowder > Independent Software Consultant > tj / crowder software / comwww.crowdersoftware.com > > On Mar 24, 10:45 am, Omar Adobati <[email protected]> wrote: > > > > > Hi T.J. > > I've set up a small minimum failing test here:http://www.adobati.it/test/ > > <http://www.adobati.it/test/>I have the same error as described above: > > > == > > Prototype.emptyFunction is not a function > > (this.options.onException || Prototype.emptyFunction)(this, exception); > > == > > > Thanks, > > > Omar > > > On Wed, Mar 24, 2010 at 10:26, T.J. Crowder <[email protected]> > > wrote: > > > Hi, > > > > Again, why not just create a minimum failing test case? Start here[1], > > > add your subclass, and if it breaks post the code. > > > > [1]http://proto-scripty.wikidot.com/self-contained-test-page > > > > -- T.J. > > > > On Mar 23, 4:39 pm, 0m4r <[email protected]> wrote: > > > > fixing a typo: > > > > > == > > > > var options = {user: 'myuser', pwd:'mypwd', type:'myType', > > > > onSuccess:'success', onException:'error'}; > > > > var url = 'http://www.url.com'; > > > > var myAjax = new myAjaxR(url, options) > > > > == > > > > -- > > > 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 > > > [email protected]. > > > To unsubscribe from this group, send email to > > > [email protected]<prototype-scriptaculou > > > s%[email protected]> > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/prototype-scriptaculous?hl=en. -- 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 [email protected]. 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.
