My SQL database generates a table that remains hidden until the search button is clicked to display the results.
I want to use ajax to update the table without refreshing the entire page. Currently, when the page refreshes, the table reverts back to being hidden, only briefly showing the content.
$(function () {
$('#searchForm').on('submit', function () {
$.ajax({
type: 'GET',
url: 'Index',
data: $('#searchForm').serialize(),
success: function () {
$("#resultsTable").removeClass("d-none");
}
});
});
});
Form:
<form asp-page="./Index" id="searchForm" method="get">
<div class="form-actions no-color">
<p>
Find by name:
<input type="text" name="SearchString" value="@Model.CurrentFilter" />
<input type="submit" value="Search" class="btn btn-default" id="searchName" />
@*<a asp-page="./Index">Back to full List</a>*@
</p>
</div>
</form>
Although the code above is functional, the page still refreshes. I believe I may have overlooked something.