I want to create a function to call the jQuery $.ajax function with a parameter that indicates the success function name that must be called after the success event.
Something like this, but I don’t know how to fill the “complete” parameter, or even if it’s possible to do this:
function callService(successFunctionName){
$.ajax({
url: "serviceURL",
type: "POST",
data: "request",
contentType: "text/xml; charset=\"utf-8\"",
complete: successFunctionName
});
}
succesFunction1(){
}
successFunction2(){
}
Edit: I have to clarify that successFunctionName is an string
If
successFunctionNameis a string you could then usewindow[successFunctionName]. If it is the function itself it should work already