Hi,
I have a slow function that does an AJAX request:
function X(param1,param2){
var params={
type: "POST",
url: "./ajax/useful.php",
data: "param1="+param1+"¶m2="+param2,
success: function(msg){
//do something
}
};
var result=$.ajax(params).responseText;
}
Everything works fine when I call X("asdf","qwerty").
Now, what I want to do is to be able to call function X as follows:
function X(param1,param2,function(){alert('hi');}){
var params={
type: "POST",
url: "./ajax/useful.php",
data: "param1="+param1+"¶m2="+param2,
success: function(msg){
/////
//I want to be able call the function in the 3rd parameter (alert in this case)
/////
}
};
var result=$.ajax(params).responseText;
}
Now you might say why don't I just call alert('hi') directly inside the success. Sure I can do this, but I want to be able to vary what goes on inside the called function (not just a simple alert('hi'), depending on who's calling X.