I have the following:
$('#EID').change(function () {
$.ajax({
url: "/Administration/stats",
data: { DataSource: $('#DataSource').val(),
EID: $('#EID').val()
},
success: function (data) {
$('#TID').html(data);
}
});
});
This works good but I want to be able to call the function () at other times and not just when EID changes. Can someone show me how I can pull out the function code into a separate block with a name and then call that function name.
Note that you must not add
()after the function name since you want to pass the function, not its return value.In case you wanted to pass some parameter to the function, you’d do it like this: