Hello, Could anybody please tell me how I would show a message or an image while the ajax request gets processed? thank you in advance for your help. this is what I came up with but it doesn''t really work: function getHTML() { var url = "./scripts/rfiles.php"; var par = ""; var myAjax = new Ajax.Updater("fm-viewdetails", url, {method: ''get'', onFailure: reportError, onLoading: showLoading, onSuccess: hideLoading}); } function reportError() { alert(''an error has occured''); } function showLoading() { $("fm-viewstatus").style.backgroundImage = "url(images/spinner.gif)"; $("fm-viewstatus").style.backgroundRepeat = "no-repeat"; $("fm-viewstatus").style.backgroundPosition = "50% 50%"; } function hideLoading() { $("fm-viewstatus").style.backgroundImage = "url(images/spacer.gif)"; } _________________________________________________________________ On the road to retirement? Check out MSN Life Events for advice on how to get there! http://lifeevents.msn.com/category.aspx?cid=Retirement
On 10/11/05, Marco M. Jaeger <mmjaeger@hotmail.com> wrote:> > > Hello, > > Could anybody please tell me how I would show a message or an image while > the ajax request gets processed? > > thank you in advance for your help. > > this is what I came up with but it doesn''t really work: > > function getHTML() { > var url = "./scripts/rfiles.php"; > var par = ""; > var myAjax = new Ajax.Updater("fm-viewdetails", url, {method: ''get'', > onFailure: reportError, onLoading: showLoading, onSuccess: hideLoading}); > } > > function reportError() { > alert(''an error has occured''); > } > function showLoading() { > $("fm-viewstatus").style.backgroundImage = "url(images/spinner.gif)"; > $("fm-viewstatus").style.backgroundRepeat = "no-repeat"; > $("fm-viewstatus").style.backgroundPosition = "50% 50%"; > } > function hideLoading() { > $("fm-viewstatus").style.backgroundImage = "url(images/spacer.gif)"; > }Element.show(''fm-viewstatus''); Element.hide(''fm-viewstatus''); I''d take a look at the typo source for some great uses of ajax like this... -- rick http://techno-weenie.net
On 11.10.2005, at 17.25, Rick Olson wrote:> On 10/11/05, Marco M. Jaeger <mmjaeger@hotmail.com> wrote: > >> >> >> Hello, >> >> Could anybody please tell me how I would show a message or an >> image while >> the ajax request gets processed? >> >> thank you in advance for your help. >> >> this is what I came up with but it doesn''t really work: >> >> function getHTML() { >> var url = "./scripts/rfiles.php"; >> var par = ""; >> var myAjax = new Ajax.Updater("fm-viewdetails", url, >> {method: ''get'', >> onFailure: reportError, onLoading: showLoading, onSuccess: >> hideLoading}); >> } >> >> function reportError() { >> alert(''an error has occured''); >> } >> function showLoading() { >> $("fm-viewstatus").style.backgroundImage = >> "url(images/spinner.gif)"; >> $("fm-viewstatus").style.backgroundRepeat = >> "no-repeat"; >> $("fm-viewstatus").style.backgroundPosition = "50% 50%"; >> } >> function hideLoading() { >> $("fm-viewstatus").style.backgroundImage = >> "url(images/spacer.gif)"; >> } >> > > Element.show(''fm-viewstatus''); > > Element.hide(''fm-viewstatus'');Combine these with the :loading and :complete options of Rails AJAX helpers [1] and you''re on the roll. link_to_remote "Delete this post", :url => { :action => "destroy", :id => post.id }, :loading => "Element.show(''fm-viewstatus'');", :complete => "Element.hide(''fm-viewstatus'');", :update => { :success => "posts", :failure => "error" } //jarkko [1] http://rails.rubyonrails.com/classes/ActionView/Helpers/ JavaScriptHelper.html> > I''d take a look at the typo source for some great uses of ajax like > this... > > -- > rick > http://techno-weenie.net > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > >-- Jarkko Laine http://jlaine.net http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2363 bytes Desc: not available Url : http://wrath.rubyonrails.org/pipermail/rails-spinoffs/attachments/20051011/04d51fce/smime.bin
thanks for your help - you guys lost me, I''m sorry. Is this stuff just working with Ruby or does it work without Ruby as well. I''m not using Ruby, maybe that''s why I''m a little lost.>From: Jarkko Laine <jarkko@jlaine.net> >Reply-To: rails-spinoffs@lists.rubyonrails.org >To: rails-spinoffs@lists.rubyonrails.org >Subject: Re: [Rails-spinoffs] show message while loading - ajax >Date: Tue, 11 Oct 2005 18:41:45 +0300 >MIME-Version: 1.0 (Apple Message framework v734) >Received: from wrath.rubyonrails.com ([70.84.143.100]) by >mc7-f6.hotmail.com with Microsoft SMTPSVC(6.0.3790.211); Tue, 11 Oct 2005 >08:43:29 -0700 >Received: from 109.70-84-143.reverse.theplanet.com >(localhost.rubyonrails.org [127.0.0.1])by wrath.rubyonrails.com (Postfix) >with ESMTP id 94DDF3993D;Tue, 11 Oct 2005 12:43:59 +0000 (GMT) >Received: from one.textdrive.com (one.textdrive.com [207.7.108.21])by >wrath.rubyonrails.com (Postfix) with ESMTP id 62E6D3993Dfor ><rails-spinoffs@lists.rubyonrails.org>;Tue, 11 Oct 2005 12:42:59 +0000 >(GMT) >Received: from [192.168.1.4] (pc035.otanner14.kas.tut.fi [195.148.53.35])by >one.textdrive.com (Postfix) with ESMTP id B1CFA45200for ><rails-spinoffs@lists.rubyonrails.org>;Tue, 11 Oct 2005 15:42:18 +0000 >(GMT) >X-Message-Info: UZmYcfFpTCezK33KNMMFc01KPAyDheFi6RAuae8kbA0>References: ><BAY101-F3A25B7EA7B2D980718967D1780@phx.gbl><48fe25b0510110725y3941b10ega7c6676896b51992@mail.gmail.com> >X-Mailer: Apple Mail (2.734) >X-BeenThere: rails-spinoffs@lists.rubyonrails.org >X-Mailman-Version: 2.1.5 >Precedence: list >List-Id: rails-spinoffs.lists.rubyonrails.org >List-Unsubscribe: ><http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs>, ><mailto:rails-spinoffs-request@lists.rubyonrails.org?subject=unsubscribe> >List-Archive: <http://wrath.rubyonrails.org/pipermail/rails-spinoffs> >List-Post: <mailto:rails-spinoffs@lists.rubyonrails.org> >List-Help: ><mailto:rails-spinoffs-request@lists.rubyonrails.org?subject=help> >List-Subscribe: ><http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs>, ><mailto:rails-spinoffs-request@lists.rubyonrails.org?subject=subscribe> >Errors-To: rails-spinoffs-bounces@lists.rubyonrails.org >Return-Path: rails-spinoffs-bounces@lists.rubyonrails.org >X-OriginalArrivalTime: 11 Oct 2005 15:43:30.0051 (UTC) >FILETIME=[87420530:01C5CE7A] > > >On 11.10.2005, at 17.25, Rick Olson wrote: > >>On 10/11/05, Marco M. Jaeger <mmjaeger@hotmail.com> wrote: >> >>> >>> >>>Hello, >>> >>>Could anybody please tell me how I would show a message or an image >>>while >>>the ajax request gets processed? >>> >>>thank you in advance for your help. >>> >>>this is what I came up with but it doesn''t really work: >>> >>>function getHTML() { >>> var url = "./scripts/rfiles.php"; >>> var par = ""; >>> var myAjax = new Ajax.Updater("fm-viewdetails", url, {method: >>>''get'', >>>onFailure: reportError, onLoading: showLoading, onSuccess: >>>hideLoading}); >>>} >>> >>>function reportError() { >>> alert(''an error has occured''); >>>} >>>function showLoading() { >>> $("fm-viewstatus").style.backgroundImage = >>>"url(images/spinner.gif)"; >>> $("fm-viewstatus").style.backgroundRepeat = >>>"no-repeat"; >>> $("fm-viewstatus").style.backgroundPosition = "50% 50%"; >>>} >>>function hideLoading() { >>> $("fm-viewstatus").style.backgroundImage = >>>"url(images/spacer.gif)"; >>>} >>> >> >>Element.show(''fm-viewstatus''); >> >>Element.hide(''fm-viewstatus''); > >Combine these with the :loading and :complete options of Rails AJAX >helpers [1] and you''re on the roll. > >link_to_remote "Delete this post", > :url => { :action => "destroy", :id => post.id }, > :loading => "Element.show(''fm-viewstatus'');", > :complete => "Element.hide(''fm-viewstatus'');", > :update => { :success => "posts", :failure => "error" } > > >//jarkko > >[1] http://rails.rubyonrails.com/classes/ActionView/Helpers/ >JavaScriptHelper.html > >> >>I''d take a look at the typo source for some great uses of ajax like >>this... >> >>-- >>rick >>http://techno-weenie.net >>_______________________________________________ >>Rails-spinoffs mailing list >>Rails-spinoffs@lists.rubyonrails.org >>http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >> >> > >-- >Jarkko Laine >http://jlaine.net >http://odesign.fi >><< smime.p7s >>>_______________________________________________ >Rails-spinoffs mailing list >Rails-spinoffs@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffsys _________________________________________________________________ On the road to retirement? Check out MSN Life Events for advice on how to get there! http://lifeevents.msn.com/category.aspx?cid=Retirement
On 10/11/05, Marco M. Jaeger <mmjaeger@hotmail.com> wrote:> thanks for your help - you guys lost me, I''m sorry. Is this stuff just > working with Ruby or does it work without Ruby as well. I''m not using Ruby, > maybe that''s why I''m a little lost.It should work fine without ruby. But, rails provides some nice ruby helpers. Anyways, this looks like a good javascript reference for prototype: http://www.sergiopereira.com/articles/prototype.js.html -- rick http://techno-weenie.net
No you do not need ruby to use this. These are calls to javascript functions you create to hid and show and image or whatever you want: onLoading: myjavascript_function_showimage(), onSuccess: function_hide_image()}); get it? -----Original Message----- From: rails-spinoffs-bounces@lists.rubyonrails.org [mailto:rails-spinoffs-bounces@lists.rubyonrails.org] On Behalf Of Marco M. Jaeger Sent: Tuesday, October 11, 2005 8:54 AM To: rails-spinoffs@lists.rubyonrails.org Subject: Re: [Rails-spinoffs] show message while loading - ajax thanks for your help - you guys lost me, I''m sorry. Is this stuff just working with Ruby or does it work without Ruby as well. I''m not using Ruby, maybe that''s why I''m a little lost.>From: Jarkko Laine <jarkko@jlaine.net> >Reply-To: rails-spinoffs@lists.rubyonrails.org >To: rails-spinoffs@lists.rubyonrails.org >Subject: Re: [Rails-spinoffs] show message while loading - ajax >Date: Tue, 11 Oct 2005 18:41:45 +0300 >MIME-Version: 1.0 (Apple Message framework v734) >Received: from wrath.rubyonrails.com ([70.84.143.100]) by >mc7-f6.hotmail.com with Microsoft SMTPSVC(6.0.3790.211); Tue, 11 Oct 2005 >08:43:29 -0700 >Received: from 109.70-84-143.reverse.theplanet.com >(localhost.rubyonrails.org [127.0.0.1])by wrath.rubyonrails.com (Postfix) >with ESMTP id 94DDF3993D;Tue, 11 Oct 2005 12:43:59 +0000 (GMT) >Received: from one.textdrive.com (one.textdrive.com [207.7.108.21])by >wrath.rubyonrails.com (Postfix) with ESMTP id 62E6D3993Dfor ><rails-spinoffs@lists.rubyonrails.org>;Tue, 11 Oct 2005 12:42:59 +0000 >(GMT) >Received: from [192.168.1.4] (pc035.otanner14.kas.tut.fi [195.148.53.35])by>one.textdrive.com (Postfix) with ESMTP id B1CFA45200for ><rails-spinoffs@lists.rubyonrails.org>;Tue, 11 Oct 2005 15:42:18 +0000 >(GMT) >X-Message-Info: UZmYcfFpTCezK33KNMMFc01KPAyDheFi6RAuae8kbA0>References: ><BAY101-F3A25B7EA7B2D980718967D1780@phx.gbl><48fe25b0510110725y3941b10ega7c6676896b51992@mail.gmail.com>>X-Mailer: Apple Mail (2.734) >X-BeenThere: rails-spinoffs@lists.rubyonrails.org >X-Mailman-Version: 2.1.5 >Precedence: list >List-Id: rails-spinoffs.lists.rubyonrails.org >List-Unsubscribe: ><http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs>, ><mailto:rails-spinoffs-request@lists.rubyonrails.org?subject=unsubscribe> >List-Archive: <http://wrath.rubyonrails.org/pipermail/rails-spinoffs> >List-Post: <mailto:rails-spinoffs@lists.rubyonrails.org> >List-Help: ><mailto:rails-spinoffs-request@lists.rubyonrails.org?subject=help> >List-Subscribe: ><http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs>, ><mailto:rails-spinoffs-request@lists.rubyonrails.org?subject=subscribe> >Errors-To: rails-spinoffs-bounces@lists.rubyonrails.org >Return-Path: rails-spinoffs-bounces@lists.rubyonrails.org >X-OriginalArrivalTime: 11 Oct 2005 15:43:30.0051 (UTC) >FILETIME=[87420530:01C5CE7A] > > >On 11.10.2005, at 17.25, Rick Olson wrote: > >>On 10/11/05, Marco M. Jaeger <mmjaeger@hotmail.com> wrote: >> >>> >>> >>>Hello, >>> >>>Could anybody please tell me how I would show a message or an image >>>while >>>the ajax request gets processed? >>> >>>thank you in advance for your help. >>> >>>this is what I came up with but it doesn''t really work: >>> >>>function getHTML() { >>> var url = "./scripts/rfiles.php"; >>> var par = ""; >>> var myAjax = new Ajax.Updater("fm-viewdetails", url, {method: >>>''get'', >>>onFailure: reportError, onLoading: showLoading, onSuccess: >>>hideLoading}); >>>} >>> >>>function reportError() { >>> alert(''an error has occured''); >>>} >>>function showLoading() { >>> $("fm-viewstatus").style.backgroundImage = >>>"url(images/spinner.gif)"; >>> $("fm-viewstatus").style.backgroundRepeat = >>>"no-repeat"; >>> $("fm-viewstatus").style.backgroundPosition = "50% 50%"; >>>} >>>function hideLoading() { >>> $("fm-viewstatus").style.backgroundImage = >>>"url(images/spacer.gif)"; >>>} >>> >> >>Element.show(''fm-viewstatus''); >> >>Element.hide(''fm-viewstatus''); > >Combine these with the :loading and :complete options of Rails AJAX >helpers [1] and you''re on the roll. > >link_to_remote "Delete this post", > :url => { :action => "destroy", :id => post.id }, > :loading => "Element.show(''fm-viewstatus'');", > :complete => "Element.hide(''fm-viewstatus'');", > :update => { :success => "posts", :failure => "error" } > > >//jarkko > >[1] http://rails.rubyonrails.com/classes/ActionView/Helpers/ >JavaScriptHelper.html > >> >>I''d take a look at the typo source for some great uses of ajax like >>this... >> >>-- >>rick >>http://techno-weenie.net >>_______________________________________________ >>Rails-spinoffs mailing list >>Rails-spinoffs@lists.rubyonrails.org >>http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >> >> > >-- >Jarkko Laine >http://jlaine.net >http://odesign.fi >><< smime.p7s >>>_______________________________________________ >Rails-spinoffs mailing list >Rails-spinoffs@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffsys _________________________________________________________________ On the road to retirement? Check out MSN Life Events for advice on how to get there! http://lifeevents.msn.com/category.aspx?cid=Retirement _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs