Hi,
Please help me with the following situation.
I have a jquery code like this:
$('#go').on('click', function () {
$.ajax({
type: 'POST',
url: 'returnPDO.php',
dataType: "json",
data: { id: "1", rows: "7" },
success: function (data) {
...CODE....
}
});
});
Now, I have another event (keypress) that I would like to execute the same code from on.click above .
$( "#searchTbl" ).keypress(function() {
$.ajax({
type: 'POST',
url: 'returnPDO.php',
dataType: "json",
data: { id: "1", rows: "7" },
success: function (data) {
...CODE....
}
});
});
It's there a way to include the whole $.ajax code only once ?
Otherwise if I change something inside on.click I need to change on keypress code as well.
Thank you