Initialize Table with blank url
Initialize Table with blank url
sbsen
Posts: 3Questions: 1Answers: 0
Dear All,
oTable = $('#MyDataTable').DataTable({
"ajax": {
"url": "",
"dataSrc": function (json) {
return json;
}
}
});
after this I want load this table later
oTable.ajax.url("../User/GatUserData").load();
problem is when url blank still a request goes to the base url
Thanks
sbsen.
This discussion has been closed.
Answers
To some extent the behaviour you are seeing is expected. DataTables doesn't to a check to see if the URL string is empty or not, and when you make a request to an empty string the browser will just get the current URL (I remember spending about a day once debugging that on an embedded browser that was running out of memory when it should have been loading icons...).
At the moment there is no way to initialise the ajax option with an empty string I'm afraid. Perhaps that is something that DataTables should allow - I've made a note of it.
At the moment you would need to use
$.ajax
and thenclear()
androws().add()
to add the new data to the table yourself (which is basically allajax.reload()
does.Allan
Dear Allan,
I have changed the function _fnBuildAjax( oSettings, data, fn )
added to check the url is empty
if(ajax.url!=="")
oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) );
Yup - that would do it. Nice one
Allan
Allan you can add this fix to next release Thanks...
The next release is likely to be a bug fix release to take account of a deprecated method in jQuery 3, with very few other features. As such it probably won't go into the next release, but rather than next major update. I'm not sure yet when that will be released.
Regards,
Allan