How do I set the datatables not to send ajax requests when the page load
How do I set the datatables not to send ajax requests when the page load

How do I set the datatables not to send ajax requests when the page loads, but to send ajax requests when I click on the query button
$(document).ready(function () {
var table = $("#example").DataTable({
scrollX: true,
destroy: true,
columns: [
{data: "name"},
{data: "position"},
{data: "office"},
{data: "age"},
{data: "startdate"},
{data: "salary"}
],
ajax: {
url: "user/findById",
data: function (d) {
d.id = $("#userId").val()
}
}
});
$("#queryUser").click(function () {
table.ajax.reload();
});
}
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @leheng ,
You can't really, as the table will try and get the data when first initialised. What you can do though, is just reinitalise the table, something like this,
Cheers,
Colin