I would like to create a function with Jquery so that I could only pass the callback name and function specification, as well as the $ .ajax function, which as an example, I do:
$.ajax({
...
success: function(){ alert("Sucesso") }
error: function(){ alert("Erro") }
...
})
I'm currently doing this:
var myFunction = function(myCallBack1, myCallBack2){
...
if(...){
myCallBack1(param);
}else{
myCallBack2(param);
}
...
}
myFunction(
function(param){ alert("callback 1" + param) },
function(param){ alert("callback 2" + param) }
)
That is, I would just like to inform the function name and what it does, just like in ajax.
I thought about defining the function by getting a json of functions, with their specific names. But I imagine you would have a nicer way to do that.