android-vtop-chennai
android-vtop-chennai copied to clipboard
Synchronous XMLHttpRequest on the main thread is deprecated
This warning occurs due to the use of async: false
while making POST
requests to the server in order to wait for the response, however the use of this is deprecated and the use of JavaScript Promise's has been suggested as an alternative. Another solution would be to call Java functions from within JavaScript when a response has been returned in the WebView
(JavaScriptInterface
).
Warning
I/chromium: [INFO:CONSOLE(9488)] "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.", source: https://vtopcc.vit.ac.in/vtop/assets/jquery/jquery-3.3.1.js (9488)
This warning occurs due to the use of async: false
in the $.ajax()
function. This is done because we need to wait to get the result before saving the data, however since using this blocks the main thread (not in our case since users don't interact directly with the WebView
) jQuery has decided to deprecate it.
One solution for this is to await the $.ajax()
calls instead of using async: false
, however I'd prefer using the vanilla JS fetch()
function to completely replace $.ajax()
. This way the POST requests would be completely independent of jQuery.