...

View Full Version : pass parameter to call back function



otnj2ee
10-03-2008, 07:54 PM
Main function:

{
var param1="test";

var param2= new test();

ajax.onreadystatechange = callBackFunc;

ajax.open(...)

}


function test(){...}

function callBackFunc(?){


}

How I can pass the param1 and param2 to the callBackFunc function?



Thanks

Scott

ess
10-03-2008, 09:17 PM
either make param1 and param2 global by declaring them outside these functions


var param1="test";

var param2= new test();

Main function:
{
ajax.onreadystatechange = callBackFunc;
ajax.open(...)
}
function test(){...}
function callBackFunc(?){
}

or, append param1 and param2 within the body of callBackFunc(param1, param2) when making the call back.

For example,

function callBackFunc(param1, param2){
alert( param1 + " " + param2);
}
window.onload = callBackFunc("Hello", "world");

an alert message will appear when the window is loaded...which is a call back in this case I guess.

Cheers
~E



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum