Is it possible to load the config of datatables async?

Is it possible to load the config of datatables async?

XeliXeli Posts: 4Questions: 1Answers: 0
edited December 2014 in Free community support

Looking at this example: http://datatables.net/reference/option/stateLoadCallback

It shows how to get the config via a synchronous ajax call. However newer versions of firefox do not support this. Is there a way to load it asynchonically?

Ideally you'd either have to accept a promise as return value, or provide a callback like fnServerData option has.

Thanks!

Answers

  • cbtdevcbtdev Posts: 39Questions: 12Answers: 0

    I am in the same boat. Chrome still allows it, but throws this warning:

    Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.

    Section 4.5.1 of the XHR spec gives the following message:

    Synchronous XMLHttpRequest outside of workers is in the process of being removed from the web platform as it has detrimental effects to the end user's experience. (This is a long process that takes many years.) Developers must not pass false for the async argument when the JavaScript global environment is a document environment. User agents are strongly encouraged to warn about such usage in developer tools and may experiment with throwing an InvalidAccessError exception when it occurs.

    While there are possible workarounds for this, hopefully this will be supported down the road as browsers phase this out.

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin

    I've just seen that message pop up in Chrome in the last few days as well. I hadn't been aware that async was going to be deprecated, but I'd say that is fair enough, it isn't an ideal solution.

    At the moment the only other option is to use the API to load in the state information - for example page() to set the paging, etc. I will look at adding a method that will accept a DataTables state saved object to restore a saved state - probably as a plug-in initially.

    Allan

This discussion has been closed.