when readyState is completed, some code would be executed but it doesn't work upon chrome browser till clearing the cache then it runs for only one time. If I refresh, That code wouldn't be executed again until clearing the cache again and it runs for only one time again. I have to execute the code when ready state is completed because it runs over a data table that wouldn't be loaded till ready state is completed. I tried executing that same code onDocumnt.ready but It doesn't find the ids of the datatable elements so nothing happened. Here's the code used :
$(document).on("readystatechange", function(e) {
if (document.readyState == "complete") {
$(`#salaries-datatable-table`).wrap("<div class='col-12' style='overflow-x:auto'></div>");
$("#salaries-datatable-table_wrapper .dt-buttons").append(`<button class="btn btn-outline-
blue btn_size">OK</button>`);
}
});
The result is: For wrapping not only the table would be wrapped but also its container div and for the appending nothing happens except for the first time the code runs after clearing cache the button would be appended and only the table would be wrapped. I hope I could explain it appropriately.