0
I would like to create a function with Jquery so that I can pass only 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") }
...
})
Currently I’m doing so:
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 name of the function and what it does, just like in ajax.
I thought of defining the function by receiving a json of functions, with their specific names. But I imagine that would have a more pleasant way of doing this.
Got it. So it’s the way I imagined it, rsrs. Thank you very much!
– hugofsousa