js-vat | Bower Component - jsvat.js
kandi X-RAY | js-vat Summary
kandi X-RAY | js-vat Summary
Simple wrapper around js-vat from John Gardner (
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Checks for a valid tax number .
js-vat Key Features
js-vat Examples and Code Snippets
Community Discussions
Trending Discussions on js-vat
QUESTION
I want to add a class (this class put a spinner in an input, but thats not the problem) when the ajax poll takes more than x seconds (probably 1500 ms). I've tried with a setInterval and then, when the poll finishes I close the interval. But this didn't run.
I use jquery to do the ajax call and I use the property "async: false", this could be the problem? If I remove this my code doesn't run well so I need the ajax poll "sync".
Thats my code:
...ANSWER
Answered 2018-Oct-16 at 09:11Yes, the async: false
is the problem. By using async: false
, you force the browser to suspend the main UI thread while the ajax call is being done. No UI updates will be allowed, no other JavaScript code can run, etc., until the ajax call completes.
async: false
is never correct. At best it makes for poor UX in any case (it freezes the tab at least, and also possibly other related tabs; on older browsers [such as IE8] it froze the whole browser UI).
Remove the async: false
and (inferring from your code) just disable sending the form / performing the action that this validation is a part of while the ajax call is pending instead.
Side note 1: 1.5 seconds is a long time to wonder whether something is happening. Suggest feedback within 250ms at the latest; immediate feedback is generally better.
Side note 2: I assume message_timer
is declared somewhere. :-) If not, the code is falling prey to what I call The Horror of Implicit Globals and you'll want to declare it somewhere that both of those functions have access to it (but not, ideally, globally).
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install js-vat
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page