jquery multipe events with one ajax function -


i have 2 jquery events using same ajax function

$(document).on("focus blur change keyup", "#bc", function () {     $.ajax({         xxxxxxxxxxxxxx     }); });   $(document).on("change", ".op", function () {     $.ajax({         xxxxxxxxxxxxxx     }); });  

is there way of combining 2 without having repeat ajax code?

i think

function x(){     $.ajax({ xxxxxxxxxxxxxx     }); }  $(document).on("change", ".op", x);   $(document).on("focus blur change keyup", "#bc", x);  

Comments