Hi, someone can help me, I am ot able to find the way how to user Ajax.updaterto test if the request give some positive or negative result. I am able only to return the result inside a div. An example is appreciated. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Don''t use Ajax.updater. Use the regular Ajax object and then pass in your own onSuccess function handler/function pointer/functor. The handler/pointer/functor will receive the response test in a HTTP request object and you can evaluate it there. -Andrew Martinez -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]On Behalf Of Il Neofita Sent: Wednesday, June 28, 2006 10:49 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] Ajax.Updater Hi, someone can help me, I am ot able to find the way how to user Ajax.updater to test if the request give some positive or negative result. I am able only to return the result inside a div. An example is appreciated. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Hi Andrew, I am not so good in Java, can you send me a basic example. Thank you On 6/28/06, Martinez, Andrew <Andrew.Martinez-9sMr025MA47QT0dZR+AlfA@public.gmane.org> wrote:> > Don''t use Ajax.updater. Use the regular Ajax object and then pass in your > own onSuccess function handler/function pointer/functor. The > handler/pointer/functor will receive the response test in a HTTP request > object and you can evaluate it there. > > > > -Andrew Martinez > > > > -----Original Message----- > *From:* rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto: > rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]*On Behalf Of *Il Neofita > *Sent:* Wednesday, June 28, 2006 10:49 AM > *To:* rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > *Subject:* [Rails-spinoffs] Ajax.Updater > > > > Hi, > someone can help me, I am ot able to find the way how to user Ajax.updaterto test if the request give some positive or negative result. > I am able only to return the result inside a div. > An example is appreciated. > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Something like this should do it: new Ajax.Request("/my/url", { asynchronous: true, onSuccess: function(r) { $("myDiv").innerHTML = "updated! new contents " + r.responseText; }, onFailure: function(r) { alert("failed!") } }) See the docs (http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request) for more info Ciao Martin On 6/28/06, Il Neofita <asteriskmail-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi Andrew, > I am not so good in Java, can you send me a basic example. > > Thank you > > > On 6/28/06, Martinez, Andrew < Andrew.Martinez-9sMr025MA47QT0dZR+AlfA@public.gmane.org> wrote: > > > Don''t use Ajax.updater. Use the regular Ajax object and then pass in > > your own onSuccess function handler/function pointer/functor. The > > handler/pointer/functor will receive the response test in a HTTP request > > object and you can evaluate it there. > > > > > > > > -Andrew Martinez > > > > > > > > -----Original Message----- > > *From:* rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto: > > rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]* On Behalf Of *Il Neofita > > *Sent:* Wednesday, June 28, 2006 10:49 AM > > *To:* rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > *Subject:* [Rails-spinoffs] Ajax.Updater > > > > > > > > Hi, > > someone can help me, I am ot able to find the way how to user > > Ajax.updater to test if the request give some positive or negative > > result. > > I am able only to return the result inside a div. > > An example is appreciated. > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
I cannot understand something with declaring this object new Ajax.Request I will request the page /my/url however, on the server side, how should look the files? I canno tunderstand how can I give a positive o negative feedback Thank you and sorry for these basic question On 6/28/06, Martin Ström <martinstromlists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Something like this should do it: > > new Ajax.Request("/my/url", { > asynchronous: true, > onSuccess: function(r) { > $("myDiv").innerHTML = "updated! new contents " + r.responseText; > }, > onFailure: function(r) { > alert("failed!") > } > }) > > > See the docs (http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request ) > for more info > > Ciao > Martin > > > On 6/28/06, Il Neofita <asteriskmail-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi Andrew, > > I am not so good in Java, can you send me a basic example. > > > > Thank you > > > > > > On 6/28/06, Martinez, Andrew < Andrew.Martinez-9sMr025MA47QT0dZR+AlfA@public.gmane.org> wrote: > > > > > Don''t use Ajax.updater. Use the regular Ajax object and then pass in > > > your own onSuccess function handler/function pointer/functor. The > > > handler/pointer/functor will receive the response test in a HTTP request > > > object and you can evaluate it there. > > > > > > > > > > > > -Andrew Martinez > > > > > > > > > > > > -----Original Message----- > > > *From:* rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto: > > > rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]* On Behalf Of *Il > > > Neofita > > > *Sent:* Wednesday, June 28, 2006 10:49 AM > > > *To:* rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > *Subject:* [Rails-spinoffs] Ajax.Updater > > > > > > > > > > > > Hi, > > > someone can help me, I am ot able to find the way how to user > > > Ajax.updater to test if the request give some positive or negative > > > result. > > > I am able only to return the result inside a div. > > > An example is appreciated. > > > > > > _______________________________________________ > > > Rails-spinoffs mailing list > > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
How your back end reports the failure is up to you. You can pass back nothing, a 0, a 1, words, etc. Its your business logic at that point and completely arbitrary. -Andrew Martinez -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]On Behalf Of Il Neofita Sent: Wednesday, June 28, 2006 12:42 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] Ajax.Updater I cannot understand something with declaring this object new Ajax.Request I will request the page /my/url however, on the server side, how should look the files? I canno tunderstand how can I give a positive o negative feedback Thank you and sorry for these basic question On 6/28/06, Martin Ström < martinstromlists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <mailto:martinstromlists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: Something like this should do it: new Ajax.Request("/my/url", { asynchronous: true, onSuccess: function(r) { $("myDiv").innerHTML = "updated! new contents " + r.responseText; }, onFailure: function(r) { alert("failed!") } }) See the docs ( <http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request> http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request ) for more info Ciao Martin On 6/28/06, Il Neofita < asteriskmail-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: Hi Andrew, I am not so good in Java, can you send me a basic example. Thank you On 6/28/06, Martinez, Andrew < <mailto:Andrew.Martinez-9sMr025MA47QT0dZR+AlfA@public.gmane.org> Andrew.Martinez-9sMr025MA47QT0dZR+AlfA@public.gmane.org> wrote: Don''t use Ajax.updater. Use the regular Ajax object and then pass in your own onSuccess function handler/function pointer/functor. The handler/pointer/functor will receive the response test in a HTTP request object and you can evaluate it there. -Andrew Martinez -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Il Neofita Sent: Wednesday, June 28, 2006 10:49 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] Ajax.Updater Hi, someone can help me, I am ot able to find the way how to user Ajax.updater to test if the request give some positive or negative result. I am able only to return the result inside a div. An example is appreciated. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
The problem is that I cannot understand how I can pass it and how I can catch it. I understand that for you it is so obvious. Can you give me an example? Please. See you On 6/28/06, Martinez, Andrew <Andrew.Martinez-9sMr025MA47QT0dZR+AlfA@public.gmane.org> wrote:> > How your back end reports the failure is up to you. You can pass back > nothing, a 0, a 1, words, etc. Its your business logic at that point and > completely arbitrary. > > > > -Andrew Martinez > > > > -----Original Message----- > *From:* rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto: > rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]*On Behalf Of *Il Neofita > *Sent:* Wednesday, June 28, 2006 12:42 PM > *To:* rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > *Subject:* Re: [Rails-spinoffs] Ajax.Updater > > > > I cannot understand something > > with declaring this object new Ajax.Request I will request the page > /my/url > however, on the server side, how should look the files? I canno > tunderstand how can I give a positive o negative feedback > > Thank you and sorry for these basic question > > On 6/28/06, *Martin Ström* <martinstromlists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > wrote: > > Something like this should do it: > > new Ajax.Request("/my/url", { > asynchronous: true, > onSuccess: function(r) { > $("myDiv").innerHTML = "updated! new contents " + r.responseText; > }, > onFailure: function(r) { > alert("failed!") > } > }) > > > See the docs ( http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request > ) for more info > > Ciao > > Martin > > > > On 6/28/06, *Il Neofita* <asteriskmail-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi Andrew, > I am not so good in Java, can you send me a basic example. > > Thank you > > On 6/28/06, *Martinez, Andrew* < Andrew.Martinez-9sMr025MA47QT0dZR+AlfA@public.gmane.org> wrote: > > Don''t use Ajax.updater. Use the regular Ajax object and then pass in your > own onSuccess function handler/function pointer/functor. The > handler/pointer/functor will receive the response test in a HTTP request > object and you can evaluate it there. > > > > -Andrew Martinez > > > > -----Original Message----- > *From:* rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto: > rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]* On Behalf Of *Il Neofita > *Sent:* Wednesday, June 28, 2006 10:49 AM > *To:* rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > *Subject:* [Rails-spinoffs] Ajax.Updater > > > > Hi, > someone can help me, I am ot able to find the way how to user Ajax.updaterto test if the request give some positive or negative result. > I am able only to return the result inside a div. > An example is appreciated. > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
In php you could have a script: <?php if (...) { // everything went fine, this will be sent to the onSuccess handler echo "the results"; } else { // there were some errors, this will be cought by prototype''s onFailure handler header("HTTP/1.1 500 Internal Server Error"); } ?> See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for a list of available error codes. Prototype will set a response as "success" if the status code is between 200 and 300. Another solution: <?php // errors if (...) echo "0"; else echo "your results here"; ?> and just use the onSuccess handler, like new Ajax.Request(url, { onSuccess: function(r) { if (r.responseText == "0") return alert("error"); alert("success"); Element.update("mydiv", t.responseText); } }) Martin On 6/28/06, Il Neofita <asteriskmail-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> The problem is that I cannot understand how I can pass it and how I can > catch it. > I understand that for you it is so obvious. > Can you give me an example? Please. > > See you > > > On 6/28/06, Martinez, Andrew <Andrew.Martinez-9sMr025MA47QT0dZR+AlfA@public.gmane.org> wrote: > > > > > > > > > > > > How your back end reports the failure is up to you. You can pass back > nothing, a 0, a 1, words, etc. Its your business logic at that point and > completely arbitrary. > > > > > > > > > > -Andrew Martinez > > > > > > > > > > > > -----Original Message----- > > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On > Behalf Of Il Neofita > > > > Sent: Wednesday, June 28, 2006 12:42 PM > > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > > Subject: Re: [Rails-spinoffs] Ajax.Updater > > > > > > > > > > > > > > > > I cannot understand something > > > > with declaring this object new Ajax.Request I will request the page > /my/url > > however, on the server side, how should look the files? I canno > tunderstand how can I give a positive o negative feedback > > > > Thank you and sorry for these basic question > > > > > > > > On 6/28/06, Martin Ström <martinstromlists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > wrote: > > > > > > Something like this should do it: > > > > new Ajax.Request("/my/url", { > > asynchronous: true, > > onSuccess: function(r) { > > $("myDiv").innerHTML = "updated! new contents " + r.responseText; > > }, > > onFailure: function(r) { > > alert("failed!") > > } > > }) > > > > > > See the docs ( > http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request > ) for more info > > > > Ciao > > > > Martin > > > > > > > > On 6/28/06, Il Neofita <asteriskmail-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > Hi Andrew, > > I am not so good in Java, can you send me a basic example. > > > > Thank you > > > > > > > > On 6/28/06, Martinez, Andrew < Andrew.Martinez-9sMr025MA47QT0dZR+AlfA@public.gmane.org> wrote: > > > > > > Don''t use Ajax.updater. Use the regular Ajax object and then pass in your > own onSuccess function handler/function pointer/functor. The > handler/pointer/functor will receive the response test in a HTTP request > object and you can evaluate it there. > > > > > > > > -Andrew Martinez > > > > > > > > > > -----Original Message----- > > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On > Behalf Of Il Neofita > > Sent: Wednesday, June 28, 2006 10:49 AM > > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > Subject: [Rails-spinoffs] Ajax.Updater > > > > > > > > Hi, > > someone can help me, I am ot able to find the way how to user Ajax.updater > to test if the request give some positive or negative result. > > I am able only to return the result inside a div. > > An example is appreciated. > > > > > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > > > > > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >
A HTTP server returns a HTTP status code with every answer. The Ajax.Request object knows about this, and will execute the onSuccess function only if a non- error status code was returned (normally "200 OK"). You can also fine-tune this by using the various methods described on the Wiki page Martin mentioned. Note that your server-side web development framework should allow you to set these status codes. What do you use on the server? For more info about this, see http://www.w3.org/Protocols/rfc2616/ rfc2616-sec10.html. -Thomas Am 28.06.2006 um 18:41 schrieb Il Neofita:> I cannot understand something > > with declaring this object new Ajax.Request I will request the > page /my/url > however, on the server side, how should look the files? I canno > tunderstand how can I give a positive o negative feedback > > Thank you and sorry for these basic question > > > On 6/28/06, Martin Ström <martinstromlists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > wrote: > Something like this should do it: > > new Ajax.Request("/my/url", { > asynchronous: true, > onSuccess: function(r) { > $("myDiv").innerHTML = "updated! new contents " + > r.responseText; > }, > onFailure: function(r) { > alert("failed!") > } > }) > > > See the docs ( http://wiki.script.aculo.us/scriptaculous/show/ > Ajax.Request ) for more info > > Ciao > Martin > > > On 6/28/06, Il Neofita <asteriskmail-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > Hi Andrew, > I am not so good in Java, can you send me a basic example. > > Thank you > > > On 6/28/06, Martinez, Andrew < Andrew.Martinez-9sMr025MA47QT0dZR+AlfA@public.gmane.org> wrote: > Don''t use Ajax.updater. Use the regular Ajax object and then pass > in your own onSuccess function handler/function pointer/functor. > The handler/pointer/functor will receive the response test in a > HTTP request object and you can evaluate it there. > > > -Andrew Martinez > > > -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails- > spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Il Neofita > Sent: Wednesday, June 28, 2006 10:49 AM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: [Rails-spinoffs] Ajax.Updater > > > Hi, > someone can help me, I am ot able to find the way how to user > Ajax.updater to test if the request give some positive or negative > result. > I am able only to return the result inside a div. > An example is appreciated. > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs-- Thomas Fuchs wollzelle http://www.wollzelle.com questentier on AIM madrobby on irc.freenode.net http://www.fluxiom.com :: online digital asset management http://script.aculo.us :: Web 2.0 JavaScript http://mir.aculo.us :: Where no web developer has gone before _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Thank you, now everything is clear. On 6/29/06, Thomas Fuchs <t.fuchs-moWQItti3gBl57MIdRCFDg@public.gmane.org> wrote:> > A HTTP server returns a HTTP status code with every answer. The > Ajax.Request object knowsabout this, and will execute the onSuccess > function only if a non-error status code was returned > (normally "200 OK"). You can also fine-tune this by using the various > methods described on > the Wiki page Martin mentioned. > > Note that your server-side web development framework should allow you to > set these status > codes. What do you use on the server? > > For more info about this, see > http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html. > > -Thomas > > > Am 28.06.2006 um 18:41 schrieb Il Neofita: > > I cannot understand something > > with declaring this object new Ajax.Request I will request the page > /my/url > however, on the server side, how should look the files? I canno > tunderstand how can I give a positive o negative feedback > > Thank you and sorry for these basic question > > > On 6/28/06, Martin Ström <martinstromlists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > wrote: > > > > Something like this should do it: > > > > new Ajax.Request("/my/url", { > > asynchronous: true, > > onSuccess: function(r) { > > $("myDiv").innerHTML = "updated! new contents " + r.responseText > > ; > > }, > > onFailure: function(r) { > > alert("failed!") > > } > > }) > > > > > > See the docs (http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request ) > > for more info > > > > Ciao > > Martin > > > > > > On 6/28/06, Il Neofita <asteriskmail-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > Hi Andrew, > > > I am not so good in Java, can you send me a basic example. > > > > > > Thank you > > > > > > > > > On 6/28/06, Martinez, Andrew < Andrew.Martinez-9sMr025MA47QT0dZR+AlfA@public.gmane.org> wrote: > > > > > > > Don''t use Ajax.updater. Use the regular Ajax object and then pass > > > > in your own onSuccess function handler/function pointer/functor. The > > > > handler/pointer/functor will receive the response test in a HTTP request > > > > object and you can evaluate it there. > > > > > > > > > > > > -Andrew Martinez > > > > > > > > > > > > -----Original Message----- > > > > *From:* rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto: > > > > rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]* On Behalf Of *Il > > > > Neofita > > > > *Sent:* Wednesday, June 28, 2006 10:49 AM > > > > *To:* rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > > *Subject:* [Rails-spinoffs] Ajax.Updater > > > > > > > > > > > > Hi, > > > > someone can help me, I am ot able to find the way how to user > > > > Ajax.updater to test if the request give some positive or negative > > > > result. > > > > I am able only to return the result inside a div. > > > > An example is appreciated. > > > > > > > > _______________________________________________ > > > > Rails-spinoffs mailing list > > > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > > > > > > > > > > _______________________________________________ > > > Rails-spinoffs mailing list > > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > -- > Thomas Fuchs > wollzelle > > http://www.wollzelle.com > > questentier on AIM > madrobby on irc.freenode.net > > http://www.fluxiom.com :: online digital asset management > http://script.aculo.us :: Web 2.0 JavaScript > http://mir.aculo.us :: Where no web developer has gone before > > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
I don''t mean to hijack the thread. I might possibly be misunderstanding Il Neofita''s intentions with positive/negative feedback. Just for clarifications here are the two meanings I can see: 1) The Ajax operation was being used to send data to the server, the server would return a true/false value based upon that data that was computed server side. 2) The Ajax operation was being attempted and the positive/negative feedback is being used to determine if the server is present, not present, or if the request failed due to some other network related problem. Now, if we are in situation #1, is it really a good idea to use HTTP response failure headers, thus triggering the onFailure event, to signify an invalid computational value? Won''t we then lose the ability to tell if the serer is simply not present? I would imagine it would be better for the server to send response text back to the client that signifies a failure. Reserving error responses for situation 2, when we really need to know that the Ajax request isn''t being computed as a failure, it just isn''t reaching the server properly. Unless situation #2 is what Il Neofita''s intention the entire time, then I am sorry to waste time. There is of course another situation, where I am completely misunderstanding the importance of onFailure..... -Andrew Martinez -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]On Behalf Of Il Neofita Sent: Thursday, June 29, 2006 4:08 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] Ajax.Updater Thank you, now everything is clear. On 6/29/06, Thomas Fuchs <t.fuchs-moWQItti3gBl57MIdRCFDg@public.gmane.org> wrote: A HTTP server returns a HTTP status code with every answer. The Ajax.Request object knows about this, and will execute the onSuccess function only if a non-error status code was returned (normally "200 OK"). You can also fine-tune this by using the various methods described on the Wiki page Martin mentioned. Note that your server-side web development framework should allow you to set these status codes. What do you use on the server? For more info about this, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html . -Thomas Am 28.06.2006 um 18:41 schrieb Il Neofita: I cannot understand something with declaring this object new Ajax.Request I will request the page /my/url however, on the server side, how should look the files? I canno tunderstand how can I give a positive o negative feedback Thank you and sorry for these basic question On 6/28/06, Martin Ström <martinstromlists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > wrote: Something like this should do it: new Ajax.Request("/my/url", { asynchronous: true, onSuccess: function(r) { $("myDiv").innerHTML = "updated! new contents " + r.responseText; }, onFailure: function(r) { alert("failed!") } }) See the docs ( http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request ) for more info Ciao Martin On 6/28/06, Il Neofita < asteriskmail-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: Hi Andrew, I am not so good in Java, can you send me a basic example. Thank you On 6/28/06, Martinez, Andrew < Andrew.Martinez-9sMr025MA47QT0dZR+AlfA@public.gmane.org> wrote: Don''t use Ajax.updater. Use the regular Ajax object and then pass in your own onSuccess function handler/function pointer/functor. The handler/pointer/functor will receive the response test in a HTTP request object and you can evaluate it there. -Andrew Martinez -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Il Neofita Sent: Wednesday, June 28, 2006 10:49 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] Ajax.Updater Hi, someone can help me, I am ot able to find the way how to user Ajax.updater to test if the request give some positive or negative result. I am able only to return the result inside a div. An example is appreciated. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Good point. I had stayed away from this thread, but I was wondering why this alternative wasn''t considered: Add an HTML comment to the responseText (the content), e.g., <!-- *ServerStatus: condition-here --> (It could even be the first line) Any condition (string, numeric or both) could tell the client-side a message without mucking with the Http conditions, which are tricky enough as they are. Maybe the content is XML? Add an XML element that describes the condition... I suppose it depends heavily on the type of data stream... perhaps modifying the http in (some) situations is correct. BTW: I''ve observed that when onFailure is called, onComplete is called immediately after. I was surprised, and it changes what processing is expected in each handler. Sam -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Martinez, Andrew Sent: Thursday, June 29, 2006 8:54 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] Ajax.Updater I dont mean to hijack the thread. I might possibly be misunderstanding Il Neofitas intentions with positive/negative feedback. Just for clarifications here are the two meanings I can see: 1) The Ajax operation was being used to send data to the server, the server would return a true/false value based upon that data that was computed server side. 2) The Ajax operation was being attempted and the positive/negative feedback is being used to determine if the server is present, not present, or if the request failed due to some other network related problem. Now, if we are in situation #1, is it really a good idea to use HTTP response failure headers, thus triggering the onFailure event, to signify an invalid computational value? Wont we then lose the ability to tell if the serer is simply not present? I would imagine it would be better for the server to send response text back to the client that signifies a failure. Reserving error responses for situation 2, when we really need to know that the Ajax request isnt being computed as a failure, it just isnt reaching the server properly. Unless situation #2 is what Il Neofitas intention the entire time, then I am sorry to waste time. There is of course another situation, where I am completely misunderstanding the importance of onFailure .. -Andrew Martinez -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]On Behalf Of Il Neofita Sent: Thursday, June 29, 2006 4:08 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] Ajax.Updater Thank you, now everything is clear. On 6/29/06, Thomas Fuchs <t.fuchs-moWQItti3gBl57MIdRCFDg@public.gmane.org> wrote: A HTTP server returns a HTTP status code with every answer. The Ajax.Request object knows about this, and will execute the onSuccess function only if a non-error status code was returned (normally "200 OK"). You can also fine-tune this by using the various methods described on the Wiki page Martin mentioned. Note that your server-side web development framework should allow you to set these status codes. What do you use on the server? For more info about this, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html . -Thomas Am 28.06.2006 um 18:41 schrieb Il Neofita: I cannot understand something with declaring this object new Ajax.Request I will request the page /my/url however, on the server side, how should look the files? I canno tunderstand how can I give a positive o negative feedback Thank you and sorry for these basic question On 6/28/06, Martin Ström <martinstromlists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > wrote: Something like this should do it: new Ajax.Request("/my/url", { asynchronous: true, onSuccess: function(r) { $("myDiv").innerHTML = "updated! new contents " + r.responseText; }, onFailure: function(r) { alert("failed!") } }) See the docs ( http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request ) for more info Ciao Martin On 6/28/06, Il Neofita < asteriskmail-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: Hi Andrew, I am not so good in Java, can you send me a basic example. Thank you On 6/28/06, Martinez, Andrew < Andrew.Martinez-9sMr025MA47QT0dZR+AlfA@public.gmane.org> wrote: Don''t use Ajax.updater. Use the regular Ajax object and then pass in your own onSuccess function handler/function pointer/functor. The handler/pointer/functor will receive the response test in a HTTP request object and you can evaluate it there. -Andrew Martinez -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Il Neofita Sent: Wednesday, June 28, 2006 10:49 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] Ajax.Updater Hi, someone can help me, I am ot able to find the way how to user Ajax.updater to test if the request give some positive or negative result. I am able only to return the result inside a div. An example is appreciated. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
The Ajax calls can also respond to specific status codes, not only a genral "success/failure" scheme. If the server isn''t available, you''ll get nothing back, btw. ;) Anyway, a possible and "clean" alternative is to use custom HTTP headers (Prototype already does this with support for a JSON header and Prototype version info). You can access custom HTTP response headers by calling the getResponseHeader(name) method on the Ajax response object you''ll get for your Ajax.Request callbacks. As mentioned, JSON (http://www.json.org/) support is built-in, read http://development.finetooth.com/?p=7 for more info. -Thomas Am 29.06.2006 um 14:54 schrieb Martinez, Andrew:> 1) The Ajax operation was being used to send data to the > server, the server would return a true/false value based upon that > data that was computed server side. > (...) > Now, if we are in situation #1, is it really a good idea to use > HTTP response failure headers, thus triggering the onFailure event, > to signify an invalid computational value? Won’t we then lose the > ability to tell if the serer is simply not present? I would imagine > it would be better for the server to send response text back to the > client that signifies a failure. Reserving error responses for > situation 2, when we really need to know that the Ajax request > isn’t being computed as a failure, it just isn’t reaching the > server properly. > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs