All, I am trying to perform a simple ajax task and am having some difficulties with the page showing the response. The action performs, but no response on the page. I have found examples on the web and I believe I have copied and pasted exactly what works from the demo site. However, on my system it isn''t finishing. For a simple test, I have limited it down to an alert. <%= link_to_remote ''Doing a JavaScript alert'', :url => {:action => ''do_alert''} %> Leaving out the rest of the code (controller, etc..) because it is irrelevant. If I modify the above to this: <%= link_to_remote ''Doing a JavaScript alert'', :url => {:action => ''do_alert''}, :complete => "eval(request.responseText)" %> It works. As such, I know the response is coming back but for some reason the page doesn''t display my results. From what I understand, the :complete should not be required. Further, I don''t want to do an alert - I want to change some text and show an image while an action is in progress, then remove the image when the action is completed. I am only doing the alert as something simple until I figure out why the page isn''t refreshing properly. Any pointers on what I am doing wrong? Thank you, Michael --------------------------------- Do you Yahoo!? Get on board. You''re invited to try the new Yahoo! Mail Beta. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060716/c627c08d/attachment.html
Matthew Margolis
2006-Jul-16 20:09 UTC
[Rails] RJS and Action Renders but page doesn''t update
Michael wrote:> All, > > I am trying to perform a simple ajax task and am having some > difficulties with the page showing the response. The action performs, > but no response on the page. > > I have found examples on the web and I believe I have copied and > pasted exactly what works from the demo site. However, on my system > it isn''t finishing. For a simple test, I have limited it down to an > alert. > > <%= link_to_remote ''Doing a JavaScript alert'', > *:url* => {*:action* => ''do_alert''} %> > > Leaving out the rest of the code (controller, etc..) because it is > irrelevant. If I modify the above to this: > > <%= link_to_remote ''Doing a JavaScript alert'', > *:url* => {*:action* => ''do_alert''}, *:complete* => > "eval(request.responseText)" %> > > It works. As such, I know the response is coming back but for some > reason the page doesn''t display my results. From what I understand, > the :complete should not be required. > > Further, I don''t want to do an alert - I want to change some text and > show an image while an action is in progress, then remove the image > when the action is completed. I am only doing the alert as something > simple until I figure out why the page isn''t refreshing properly. Any > pointers on what I am doing wrong? > > Thank you, > > Michael > > > ------------------------------------------------------------------------ > Do you Yahoo!? > Get on board. You''re invited > <http://us.rd.yahoo.com/evt=40791/*http://advision.webevents.yahoo.com/handraisers> > to try the new Yahoo! Mail Beta. > ------------------------------------------------------------------------ > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >It would be really helpful if you could paste your rjs and the relevant part of the controller. If you are using Firefox then I recommend that you get Firebug and check out the actual request and response that your link is causing. Matthew Margolis blog.mattmargolis.net
Matthew Margolis wrote:> Michael wrote: >> >> It works. As such, I know the response is coming back but for some >> >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > It would be really helpful if you could paste your rjs and the relevant > part of the controller. > If you are using Firefox then I recommend that you get Firebug and check > out the actual request and response that your link is causing. > > Matthew Margolis > blog.mattmargolis.netHi Matthew, do_alert.rjs: page.alert "This is a test alert!!!" Controller: def do_alert end That''s pretty basic, huh? I have tried a few different examples with no luck. I''m sure I''m missing something basic! Your help is appreciated. Michael -- Posted via http://www.ruby-forum.com/.
Kevin Olbrich
2006-Jul-16 23:49 UTC
[Rails] Re: RJS and Action Renders but page doesn''t update
On Monday, July 17, 2006, at 12:32 AM, Michael wrote:>Matthew Margolis wrote: >> Michael wrote: >>> >>> It works. As such, I know the response is coming back but for some >>> >>> _______________________________________________ >>> Rails mailing list >>> Rails@lists.rubyonrails.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails >>> >> It would be really helpful if you could paste your rjs and the relevant >> part of the controller. >> If you are using Firefox then I recommend that you get Firebug and check >> out the actual request and response that your link is causing. >> >> Matthew Margolis >> blog.mattmargolis.net > >Hi Matthew, > >do_alert.rjs: > > page.alert "This is a test alert!!!" > >Controller: > > def do_alert > > end > >That''s pretty basic, huh? I have tried a few different examples with no >luck. I''m sure I''m missing something basic! > >Your help is appreciated. > >Michael > > >-- >Posted via http://www.ruby-forum.com/. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/railsI presume you are including the appropriate javascript files in your layout. _Kevin www.sciwerks.com -- Posted with http://DevLists.com. Sign up and save your mailbox.
Kevin Olbrich wrote:> On Monday, July 17, 2006, at 12:32 AM, Michael wrote: >>> It would be really helpful if you could paste your rjs and the relevant >> >> >>http://lists.rubyonrails.org/mailman/listinfo/rails > I presume you are including the appropriate javascript files in your > layout. > > _Kevin > www.sciwerks.comKevin, Yes - I have the javascripts included as per <%= javascript_include_tag :defaults %> Remember, the :complete => "eval(request.responseText)" statement allows me to see the returned code. Thank you... Michael -- Posted via http://www.ruby-forum.com/.
Michael wrote:> Kevin Olbrich wrote: >> On Monday, July 17, 2006, at 12:32 AM, Michael wrote: >>>> It would be really helpful if you could paste your rjs and the relevant >>> >>> >>>http://lists.rubyonrails.org/mailman/listinfo/rails >> I presume you are including the appropriate javascript files in your >> layout. >> >> _Kevin >> www.sciwerks.com > > Kevin, > > Yes - I have the javascripts included as per > <%= javascript_include_tag :defaults %> > > Remember, the :complete => "eval(request.responseText)" statement allows > me to see the returned code. > > Thank you... > > MichaelOkay - Now I am limiting this to just one question! I have changed from the "alert" test to something more along the lines of what I want. I''m updating a div with something and adding a visual effect. I spent the 10 bucks and bought Cody Fauser''s eBook titled "RJS Templates for Rails" and cut and paste the very first sample. It did not work, as suspected. I simply added the ":complete => "eval..." and it worked fine. So I guess my only question is why am I having to put the :complete... portion in my code when it doesn''t appear that other samples, including Cody''s, require that? Thanks, Michael -- Posted via http://www.ruby-forum.com/.
Matthew Margolis
2006-Jul-17 04:18 UTC
[Rails] Re: RJS and Action Renders but page doesn''t update
Michael wrote:> Michael wrote: > >> Kevin Olbrich wrote: >> >>> On Monday, July 17, 2006, at 12:32 AM, Michael wrote: >>> >>>>> It would be really helpful if you could paste your rjs and the relevant >>>>> >>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>> >>> I presume you are including the appropriate javascript files in your >>> layout. >>> >>> _Kevin >>> www.sciwerks.com >>> >> Kevin, >> >> Yes - I have the javascripts included as per >> <%= javascript_include_tag :defaults %> >> >> Remember, the :complete => "eval(request.responseText)" statement allows >> me to see the returned code. >> >> Thank you... >> >> Michael >> > > > > Okay - Now I am limiting this to just one question! I have changed from > the "alert" test to something more along the lines of what I want. I''m > updating a div with something and adding a visual effect. I spent the > 10 bucks and bought Cody Fauser''s eBook titled "RJS Templates for Rails" > and cut and paste the very first sample. It did not work, as suspected. > I simply added the ":complete => "eval..." and it worked fine. So I > guess my only question is why am I having to put the :complete... > portion in my code when it doesn''t appear that other samples, including > Cody''s, require that? > > > Thanks, > > Michael > >What version of Rails are you running? Have you tried using inline rjs in your controller? If you can get Firefox and Firebug and post the XMLHTTPrequest and response for us that would be great. Matthew Margolis blog.mattmargolis.net
Michael
2006-Jul-17 16:23 UTC
[Rails] Re: Re: RJS and Action Renders but page doesn''t update
Matthew Margolis wrote:> Michael wrote: >>>> I presume you are including the appropriate javascript files in your >>> Remember, the :complete => "eval(request.responseText)" statement allows >> the "alert" test to something more along the lines of what I want. I''m >> >> Michael >> >> > What version of Rails are you running? Have you tried using inline rjs > in your controller? If you can get Firefox and Firebug and post the > XMLHTTPrequest and response for us that would be great. > > Matthew Margolis > blog.mattmargolis.netHi Matthew, I''m on Rails 1.1.2. I did try inline RJS as well with same results. To date, I haven''t used Firebug but I will install it sometime this week and play around with it to see what is going on. For now, I have working what I need and actually ended up needing to put in the :complete anyway (along with :loading) in order to set the progress indicator properly and hide it upon completion. Cody''s eBook on RJS Templates had an example of exactly what I was trying to do, so it was worth the $10.00. I have a long running action (pdf file creation that gets emailed to a user) and simply wanted to allow the user to do this via an ajax call so they could get a visible clue that they not only clicked the button but that it was doing something in the background. I''m beginning to think that the :complete must be a default setting that isn''t being set in my application. It was mostly frustrating to me because I was using examples found on the web w/o this setting and couldn''t get anything to work (actually, to display the updated values). I guess for me it is more of a "why didn''t it work" question. Having worked with XMLHTTPRequests many years ago via Javascript and MSXMLHTTP, I can say that I LOVE the RJS functionality. It is so clean and once you figure out how to use it - it is very cool. Regards, Michael -- Posted via http://www.ruby-forum.com/.