(Testado em http://jsfiddle.net/ivan_sim/BYQTY/ )
Exemplo 1 – Via chamada de retorno anônima
$("#example").click(function() {
echoCallbackParams(params);
});
function echoCallbackParams(params) {
console.log(params);
}
Exemplo 2- Via API jQuery predefinida (.click e .ajaxSuccess)
$("#example").click(params, echoCallbackEventParams);
function echoCallbackEventParams(params) {
console.log(params.data);
}
$("#example").click(function() {
$.getJSON("/echo/jsonp/", params, echoSuccess);
});
function echoSuccess(params, textStatus, jqXHR) {
console.log("Text status: " + textStatus);
console.log(params;
console.log(jqXHR);
};
Exemplo 3- Via Callback Nomeado
fetchData(getJsonData, "/echo/jsonp/", params);
function fetchData(dataAccess, url, params) {
dataAccess(url, params, echoSuccess);
};
function getJsonData(url, params, onSuccess) {
$.getJSON(url, params, onSuccess);
};