Hi all. I my apps I need to use Ajax.Request Object. One of the object options is onComplete fuction which looks like this: funcion onComplete (originalResponse) { ..some operations } I need pass to function one more parameter, how to do it? is is possible? I can''t use AJAX Updater because result of Ajax Call is uploaded to the div that I defined earlier, and in my situations I don''t know id of my html element. I need to do something like this: funcion onComplete(originalResponse,param1) { if (param1 != something) $(''result'').value = originalRequest.responseText; else $(''resultSecond'').value = originalRequest.responseText; } How to achieve this? ---------------------------------------------------- W kwietniowym numerze "Zwierciadła" "3 x Malle" - płyty z filmami Louise Malle''a i konkurs z cennymi nagrodami. Z nowym numerem "Milou w maju" na DVD. http://klik.wp.pl/?adr=http%3A%2F%2Fadv.reklama.wp.pl%2Fas%2Fzwierciadlo3.html&sid=714
On 4/6/06, Grzesiek Slusarek <gregtech-5tc4TXWwyLM@public.gmane.org> wrote:> Hi all. I my apps I need to use Ajax.Request Object. One of the object options is onComplete fuction which looks like this: > funcion onComplete (originalResponse) > { > ..some operations > } > I need pass to function one more parameter, how to do it? is is possible? I can''t use AJAX Updater because result of Ajax Call is uploaded to the div that I defined earlier, and in my situations I don''t know id of my html element. I need to do something like this: > funcion onComplete(originalResponse,param1) > { > if (param1 != something) > $(''result'').value = originalRequest.responseText; > else > $(''resultSecond'').value = originalRequest.responseText; > } > How to achieve this? >What is the need ? Where does param1 come from ?
Dnia 6-04-2006 o godz. 14:01 Nicolas Terray napisał(a):> On 4/6/06, Grzesiek Slusarek <gregtech-5tc4TXWwyLM@public.gmane.org> wrote: > > Hi all. I my apps I need to use Ajax.Request Object. One of the object > options is onComplete fuction which looks like this: > > funcion onComplete (originalResponse) > > { > > ..some operations > > } > > I need pass to function one more parameter, how to do it? is is > possible? I can''t use AJAX Updater because result of Ajax Call is > uploaded to the div that I defined earlier, and in my situations I don''t > know id of my html element. I need to do something like this: > > funcion onComplete(originalResponse,param1) > > { > > if (param1 != something) > > $(''result'').value = originalRequest.responseText; > > else > > $(''resultSecond'').value = originalRequest.responseText; > > } > > How to achieve this? > > > > What is the need ? Where does param1 come from ?Well that was only definition of the funcion, where it come from? I want to put param1 in the Ajax.Request object: var myAjax = new Ajax.Request( url, {method: ''get'', parameters: pars, onComplete: showResponse;param1 }); Something like code above? But is it possible, is there a nice way to do This? I think that there is great need to do something with Ajax response depend on some variable.. But we have only Ajax Reqeust that response must be prepare by user or AJAX Updater that is allways putted in the html, and e.g. if I get Ajax result from serwer I want to decide should I put result in to html or brake it off. Any help will be appraciated, sorry for my bad english ---------------------------------------------------- Uroda, horoskopy, zdrowie, moda - sprawdź sama http://klik.wp.pl/?adr=www.kobieta.wp.pl&sid=715
Grzesiek Slusarek wrote:> Well that was only definition of the funcion, where it come from? > I want to put param1 in the Ajax.Request object: > var myAjax = new Ajax.Request( > url, > {method: ''get'', > parameters: pars, > onComplete: showResponse;param1 > }); > Something like code above? > But is it possible, is there a nice way to do This?I think you can do something like this: onComplete: (function(param1, transport, json) { // your code }).bind(myAjax, ''value1''); They key here is that Function.bind allows you to set default parameters. json is passed by respondToReadyState although it''ll be undefined unless you''re sending back X-JSON, so it could probably be dropped. Todd -- Posted via http://www.ruby-forum.com/.
On 4/6/06, Grzesiek Slusarek <gregtech-5tc4TXWwyLM@public.gmane.org> wrote:> > What is the need ? Where does param1 come from ? > > Well that was only definition of the funcion, where it come from? > I want to put param1 in the Ajax.Request object: > var myAjax = new Ajax.Request( > url, > {method: ''get'', > parameters: pars, > onComplete: showResponse;param1 > }); > Something like code above?Something like code below? function showResponse(originalRequest, param) { } var myAjax = new Ajax.Request( url, { onComplete: function(originalRequest) { showResponse(roriginalRequest, param1); } });