I''m using a class I found that evals responseText from AJAX.Requests, judging by my Firebug results it works like a charm, however, I''m having difficulty displaying the data in a DIV. Code: <script> Ajax.Eval = Class.create(); Object.extend(Object.extend(Ajax.Eval.prototype, Ajax.Request.prototype), { initialize: function(url, pars) { this.transport = Ajax.getTransport(); this.setOptions({method:''post'', parameters:pars}); this.options.onComplete = (function(transport) { eval(transport.responseText); }); this.request(url); } }); function runAjax(target) { var myAjax = new Ajax.Eval(''getlrudetail.cfm?id=30020'', {method:''get''}); $(target).innerHTML = myAjax.responseText; // Returns "Undefined" in my DIV space. } </script> I''m pretty new to JavaScript in general but I''m working on an internal AJAX app (which is working wonderfully, but it''s a big hack so I''m trying to go about re-developing the proper way). I think the code is pretty self-explainatory, I just need a way to display the responseText from the call. Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I am not sure what you are trying to do. But you may consider looking at the Ajax.Updater. But, the reason that is undefined is because you are treating the Ajax call as synchronous. Anything you need to do with responseText needs to be done in the onComplete function. nds On 2/6/07, Matthew Williams <matthew.d.williams-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I''m using a class I found that evals responseText from AJAX.Requests, > judging by my Firebug results it works like a charm, however, I''m > having difficulty displaying the data in a DIV. > > Code: > <script> > Ajax.Eval = Class.create(); > Object.extend(Object.extend(Ajax.Eval.prototype, > Ajax.Request.prototype), { > initialize: function(url, pars) { > this.transport = Ajax.getTransport(); > this.setOptions({method:''post'', parameters:pars}); > this.options.onComplete = (function(transport) { > eval(transport.responseText); > }); > this.request(url); > } > }); > function runAjax(target) { > var myAjax = new Ajax.Eval(''getlrudetail.cfm?id=30020'', > {method:''get''}); > $(target).innerHTML = myAjax.responseText; // Returns "Undefined" in > my DIV space. > } > </script> > > I''m pretty new to JavaScript in general but I''m working on an internal > AJAX app (which is working wonderfully, but it''s a big hack so I''m > trying to go about re-developing the proper way). > > I think the code is pretty self-explainatory, I just need a way to > display the responseText from the call. > > Thanks! > > > > >-- Blog: http://www.simpltry.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I was using AJAX.Updater with evalScripts but it doesn''t fully eval all the JavaScript so I was being returned plaintext and no rendering of some widgets. I''ll see what I can do with onComplete. Thanks! On Feb 6, 11:07 am, "Nicholas Schlueter" <schlue...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am not sure what you are trying to do. But you may consider looking > at the Ajax.Updater. > > But, the reason that is undefined is because you are treating the Ajax > call as synchronous. Anything you need to do with responseText needs > to be done in the onComplete function. > > nds > > On 2/6/07, Matthew Williams <matthew.d.willi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > I''m using a class I found that evals responseText from AJAX.Requests, > > judging by my Firebug results it works like a charm, however, I''m > > having difficulty displaying the data in a DIV. > > > Code: > > <script> > > Ajax.Eval = Class.create(); > > Object.extend(Object.extend(Ajax.Eval.prototype, > > Ajax.Request.prototype), { > > initialize: function(url, pars) { > > this.transport = Ajax.getTransport(); > > this.setOptions({method:''post'', parameters:pars}); > > this.options.onComplete = (function(transport) { > > eval(transport.responseText); > > }); > > this.request(url); > > } > > }); > > function runAjax(target) { > > var myAjax = new Ajax.Eval(''getlrudetail.cfm?id=30020'', > > {method:''get''}); > > $(target).innerHTML = myAjax.responseText; // Returns "Undefined" in > > my DIV space. > > } > > </script> > > > I''m pretty new to JavaScript in general but I''m working on an internal > > AJAX app (which is working wonderfully, but it''s a big hack so I''m > > trying to go about re-developing the proper way). > > > I think the code is pretty self-explainatory, I just need a way to > > display the responseText from the call. > > > Thanks! > > -- > Blog:http://www.simpltry.com/- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Just guessing from a quick glance try: myAjax.transport.responseText -Andrew Martinez -----Original Message----- From: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-spinoffs@googlegroups.com]On Behalf Of Matthew Williams Sent: Tuesday, February 06, 2007 10:48 AM To: Ruby on Rails: Spinoffs Subject: [Rails-spinoffs] Displaying AJAX.Request object contents? I''m using a class I found that evals responseText from AJAX.Requests, judging by my Firebug results it works like a charm, however, I''m having difficulty displaying the data in a DIV. Code: <script> Ajax.Eval = Class.create(); Object.extend(Object.extend(Ajax.Eval.prototype, Ajax.Request.prototype), { initialize: function(url, pars) { this.transport = Ajax.getTransport(); this.setOptions({method:''post'', parameters:pars}); this.options.onComplete = (function(transport) { eval(transport.responseText); }); this.request(url); } }); function runAjax(target) { var myAjax = new Ajax.Eval(''getlrudetail.cfm?id=30020'', {method:''get''}); $(target).innerHTML = myAjax.responseText; // Returns "Undefined" in my DIV space. } </script> I''m pretty new to JavaScript in general but I''m working on an internal AJAX app (which is working wonderfully, but it''s a big hack so I''m trying to go about re-developing the proper way). I think the code is pretty self-explainatory, I just need a way to display the responseText from the call. Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---