View Full Version : Pass a paramter to AJAX request handler??
10-19-2006, 10:12 PM
I am using ajax to get some data back from the server. I want to insert this data on my page at some element in the document (where depends on where the viewer clicked on the page). So I would like to remember what element on the page was clicked. Is there a way to pass a parameter to the function that will gain control when a response comes back from the server. I find that if I add a parameter to the following statement:
http_request.onreadystatechange = do_whatever;
http_request.onreadystatechange = do_whatever(parameter);
then I get nothing at all bacl from the server. Is there some way that I can pass my parameter to the function I have indicated for http_request.onreadystatechange?
10-20-2006, 05:49 AM
i guess you could try
http_request.onreadystatechange(parameter) = do_whatever(parameter);
but the logioc is that if u clicked different button, u get different response from server, so u dont need that parameter.
10-20-2006, 03:13 PM
Thanks much for your response. I tried your suggestion, but I got an error indicating that onreadystatechange is not a function (which means it cannot recognize a parameter in the way you suggested passing it). As far as not needing a parameter because a different button is clicked and therefore a different response is coming back from the server -- no, the reason I need a parameter is that I have mutliple DOM elements with buttons on them and I need to remember which element generated the request so that on return from the server I can expand the particular element on the page (with the data I am getting back from the server). I am not simply doing an innerhtml rewrite of an element on the page, as many ajax applications do. Instead, I am expanding (appending to) a specific DOM element based on which one was clicked.
06-03-2009, 11:19 PM
Hi Gorilla ..
There is another way to pass a parameter ..
var vparam = param;
this.Handle = function()
var handler = new AJAXHandler("This is just a by pass");
http_request.onreadystatechange = handler.Handle();
Be Happy !!
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.