Hello! This is my first post so hello to the ROR community :) I am implementing an online editor using the prototype.js lib. On one of the ajax.request calls I make something weird happens. In the debugger I get this output: ==================10:36:04:796 [DEBUG] FileBrowser.onServiceResult > inResult = success 10:36:04:812 [DEBUG] FileBrowser.onServiceResult > inResult = exception | inRequest.responseText = undefined | inException = TypeError: this.inspect is not a function ================== Now my inspect metod for this class looks very simple and it didn''t have conflicts in other classes: inspect: function() { return ''FileBrowser''; }, So basically this debugging helper function causes the exception in the onServiceResult method after a successfull response. In my Ajax.options I have: onException : this.onServiceResult.bind(this, ''exception'') and inside onServiceResult the switch looks like this: switch(inResult){ case ''success'': ... break; case ''404'': ... break; case ''failure'': ... break; case ''exception'': ... break; default: ... break; } I used jsLint to clean the code and right now I''m clueless so any hint would be hugely appreciated. Thank you ------------------------------------------------------------------------------------------- Cosmin Cimpoi Web Developer - Team Technology (OT) ------------------------------------------------------------------------------------------- monogroup Srl piata unirii nr 4-5 400013, Cluj-Napoca, Romania tel. (+40) 264594667 fax. (+40) 264594667 mail. cosmin.cimpoi-qZ0t5ilwAP73oGB3hsPCZA@public.gmane.org www.monogroup.ro ------------------------------------------------------------------------------------------- This message is confidential and intended solely for the use by the addressee. Any use of this message by a third party is prohibited. If you received this message in error, please contact the sender and delete the data from any computer and data carrier. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
On 3/17/06, Cosmin Cimpoi <cosmin.cimpoi-qZ0t5ilwAP73oGB3hsPCZA@public.gmane.org> wrote:> On one of the ajax.request calls I make something weird happens. In the > debugger I get this output: > ==================> 10:36:04:796 [DEBUG] FileBrowser.onServiceResult > inResult = success > 10:36:04:812 [DEBUG] FileBrowser.onServiceResult > inResult = exception | > inRequest.responseText = undefined | inException = TypeError: this.inspect > is not a function > ==================> > Now my inspect metod for this class looks very simple and it didn''t have > conflicts in other classes:''this'' might not be the object you''re thinking of. It''s most likely a closure problem, but we''d need to see more of the code to be sure. Todd
Thanks for the reply. I''m pretty good at using bind all over where functions might get out of scope so it''s not that. But I''ve managed to solve the problem. The thing is that on success I was doing some method callback that caused a TypeError error. And in prototype there''s this line that executed right after I was causing the error: catch (e) { this.dispatchException(e); } Thus the Ajax obj catches this TypeError error in the "respondToReadyState" routine and fires it as an Ajax exeption AFTER success. And Firefox does not show the TypeError error because it''s beeing catched by Ajax. Could be a bug but could also be that I am a beginner with prototype.js If it were a bug it would say: "be careful not to write bad code when you get a succesful Ajax reply because it''ll imediately be replaced with an exception" So far prototype rocks for me. Respekt! ----- Original Message ----- From: "Todd Ross" <rails-spinoffs-25kFIyuv2iRiLUuM0BA3LQ@public.gmane.org> To: <rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> Sent: Friday, March 17, 2006 1:45 PM Subject: Re: [Rails-spinoffs] ajax exception On 3/17/06, Cosmin Cimpoi <cosmin.cimpoi-qZ0t5ilwAP73oGB3hsPCZA@public.gmane.org> wrote:> On one of the ajax.request calls I make something weird happens. In the > debugger I get this output: > ==================> 10:36:04:796 [DEBUG] FileBrowser.onServiceResult > inResult = success > 10:36:04:812 [DEBUG] FileBrowser.onServiceResult > inResult = exception > | > inRequest.responseText = undefined | inException = TypeError: this.inspect > is not a function > ==================> > Now my inspect metod for this class looks very simple and it didn''t have > conflicts in other classes:''this'' might not be the object you''re thinking of. It''s most likely a closure problem, but we''d need to see more of the code to be sure. Todd _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs