hi all,
i''d like to know if there''s a way to send parameters to a
callback in
Prototype. For example, i have a code like:
function getRSS() {
var url = "feed.xhtml";
var myAjax = new Ajax.Request( url, {method: ''get'',
parameters:
parms, onComplete: processRSS} );
}
function processRSS(xmlHttpRequest, responseHeader) {
var xmlString = xmlHttpRequest.responseText;
alert (xmlString);
}
would be possible to give more parameters to processRSS() and do
something like...
function processRSS(xmlHttpRequest, responseHeader, foo) {
var xmlString = xmlHttpRequest.responseText;
if (foo){
alert (xmlString);
}
}
thanks in advance for your help,
Luis
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Something like this...
var myAjax = new Ajax.Request( url, {method: ''get'',
parameters:
parms, onComplete: processRSS.curry(foo)} );
I used to do this all the time in my classes with Function#bind but
since 1.6 they have introduced curry(We cooking rice?) which is a slim
downed version of bind specifically targeted to your use case. enjoy!
As a side note, things may not be as you first expect, the curried
parameter is going to come through first you''ll be looking at a
signature more like this...
function processRSS(foo, xmlHttpRequest, responseHeader ) {
Techy demo, gotta look at the source and firebug console to see whats
happenin, http://positionabsolute.net/projects/javascript/CurryTest/
--
Matt Foster
Ajax Engineer
Nth Penguin, LLC
http://www.nthpenguin.com
On Jun 26, 2:02 pm, ljundie
<ljun...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> hi all,
>
> i''d like to know if there''s a way to send parameters to a
callback in
> Prototype. For example, i have a code like:
>
> function getRSS() {
> var url = "feed.xhtml";
> var myAjax = new Ajax.Request( url, {method:
''get'', parameters:
> parms, onComplete: processRSS} );
> }
>
> function processRSS(xmlHttpRequest, responseHeader) {
>
> var xmlString = xmlHttpRequest.responseText;
>
> alert (xmlString);
>
> }
>
> would be possible to give more parameters to processRSS() and do
> something like...
>
> function processRSS(xmlHttpRequest, responseHeader, foo) {
>
> var xmlString = xmlHttpRequest.responseText;
>
> if (foo){
> alert (xmlString);
> }
> }
>
> thanks in advance for your help,
> Luis
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
function getRSS(*memo*) {
var url = "feed.xhtml";
var myAjax = new Ajax.Request(url, {
method: ''get'',
parameters: parms,
onComplete: function(res, headers) {
processRSS(res, headers, *memo*);
});
}
function processRSS(res, header, *memo*) {
...
}
getRSS(*myMemo*);
-Fred
On Thu, Jun 26, 2008 at 1:02 PM, ljundie
<ljundie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> hi all,
>
>
> i''d like to know if there''s a way to send parameters to a
callback in
> Prototype. For example, i have a code like:
>
>
>
> function getRSS() {
> var url = "feed.xhtml";
> var myAjax = new Ajax.Request( url, {method:
''get'', parameters:
> parms, onComplete: processRSS} );
> }
>
> function processRSS(xmlHttpRequest, responseHeader) {
>
> var xmlString = xmlHttpRequest.responseText;
>
> alert (xmlString);
>
> }
>
>
> would be possible to give more parameters to processRSS() and do
> something like...
>
> function processRSS(xmlHttpRequest, responseHeader, foo) {
>
> var xmlString = xmlHttpRequest.responseText;
>
> if (foo){
> alert (xmlString);
> }
> }
>
>
> thanks in advance for your help,
> Luis
> >
>
--
Science answers questions; philosophy questions answers.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
hi! both options work fine, many thanks for your help :) On 26 jun, 21:20, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote:> function getRSS(*memo*) { > var url = "feed.xhtml"; > var myAjax = new Ajax.Request(url, { > method: ''get'', > parameters: parms, > onComplete: function(res, headers) { > processRSS(res, headers, *memo*); > }); > > } > > function processRSS(res, header, *memo*) { > ... > > } > > getRSS(*myMemo*); > > -Fred > > > > > > On Thu, Jun 26, 2008 at 1:02 PM, ljundie <ljun...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > hi all, > > > i''d like to know if there''s a way to send parameters to a callback in > > Prototype. For example, i have a code like: > > > function getRSS() { > > var url = "feed.xhtml"; > > var myAjax = new Ajax.Request( url, {method: ''get'', parameters: > > parms, onComplete: processRSS} ); > > } > > > function processRSS(xmlHttpRequest, responseHeader) { > > > var xmlString = xmlHttpRequest.responseText; > > > alert (xmlString); > > > } > > > would be possible to give more parameters to processRSS() and do > > something like... > > > function processRSS(xmlHttpRequest, responseHeader, foo) { > > > var xmlString = xmlHttpRequest.responseText; > > > if (foo){ > > alert (xmlString); > > } > > } > > > thanks in advance for your help, > > Luis > > -- > Science answers questions; philosophy questions answers.- Ocultar texto de la cita - > > - Mostrar texto de la cita ---~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---