To do that, you're using the function named
filter
. You need to handle this event and prevent the form to be submitted (which is the actual intended action to be triggered when user clicks on submit button). To prevent this, you can add
event.preventDefault();
To prevent the default functionality of
any event. This would help you to create your own manual functions for every event. Thus, you function would now be like this,
function filter() {
event.preventDefault();
debugger;
$.ajax({
type: "POST"
, url: "Dashboards/Filter"
, data: JSON.stringify({ filterText: $("#txtFilter").val() })
, contentType: 'application/json;'
, success: function (result) {
$("#tbldash").html(result);
}
});
});
You should add this code at the top of the event handling code. So that, JavaScript can guide the browser to ignore handling the event itself and allow you to handle the event, in a way that you want it to be handled. You can read more about this function on
MDN[
^].