I'm using a $.ajax function that serves two purposes and depending on the context, I want to execute different functions on the call-back.
function MyAjaxCall(SomeParameter, CallBackFunctionName) {
$.ajax({
...
success: function (msg) {
var TheData = msg.hasOwnProperty("d") ? msg['d'] : msg;
// here: "execute the function in parameter CallBackFunctionName
// AND pass it the parameter TheData
}
}
How do I write the line where the name of the function is a parameter and I want to pass it TheData as the parameter.
Note, at the moment, I'm writing it like that:
if (CallBackFunctionName === "SomeFunctionName1") {
SomeFunctionName1(TheData);
} else {
SomeFunctionName2(TheData);
}