Thread Safety in Javascript?

后端 未结 5 1391
无人及你
无人及你 2020-12-05 00:33

I have a function called save(), this function gathers up all the inputs on the page, and performs an AJAX call to the server to save the state of the user\'s work.

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-05 01:07

    All major browsers only support one javascript thread (unless you use web workers) on a page.

    XHR requests can be asynchronous, though. But as long as you disable the ability to save until the current request to save returns, everything should work out just fine.

    My only suggestion, is to make sure you indicate to the user somehow when an autosave occurs (disable the save button, etc).

提交回复
热议问题