New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
client_side_validations uses synchronous ajax #226
Comments
Ok I did the same thing but only for the remote validators. There's 2 or 3 test failures which I'm not sure why they're happening. Some event seems to not get run somewhere. Also the ajax is still synchronous, once the callback refactoring is finished it should be easy to switch it to async. And I haven't tested it in an actual form yet, just the QUnit tests. branch: https://github.com/morganchristiansson/client_side_validations/commits/refactor2 |
bcardarella, I'd like your feedback on my early changes on whether you agree with this change and am willing to accept my final changes to make the ajax call asynchronous using callbacks. Thanks. |
Also I'm most interested of whether you agree with the way I've implemented callbacks than code style etc. I'm happy stay consistent with any code standards you've used etc. |
I'd definitely support the development of this feature - the hang on the uniqueness test is a really messy. I will try to check out your branch if/when I get the chance. |
Cool dapbot, it's nowhere near finished though, but I think it's a good start. An easier way might be to just remove uniqueness validations? Most of the time it's not that critical to this check client side. |
I'm sorry I let this go stale. I am very interested in picking up where this left off if anybody is interested. |
We need to use jQuery promises for the validators. |
I would like to switch to promise-based validators |
From the jQuery documentation:
http://api.jquery.com/jQuery.ajax/
Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active.
Here's an article microsoft wrote about it:
http://blogs.msdn.com/b/wer/archive/2011/08/03/why-you-should-use-xmlhttprequest-asynchronously.aspx
8.4% of all hangs in IE9 in the past month are caused by XMLHttpRequest objects blocking the UI thread with a synchronous request. That’s a huge number! With some manageable code changes, these hangs can be avoided, and developers can give their users a better experience across their websites.
Which inspired a discussion on reddit about synchronous requests: http://www.reddit.com/r/programming/comments/j89cj/84_of_all_hangs_in_ie9_in_the_past_month_caused/
It's noticeable when using as the browser momentarily freezes while typing, it also looses keypresses when i try to tab between the text fields quickly.
I started a refactoring to address this in my fork, please have a look and see what you think.morganchristiansson@19f72ee#diff-1 .It's very much a work in progress. I haven't finished the logic in validateElement() yet, all validator tests need to be refactored to use callbacks so there's 64 test failures. I thought I'd ask your opinion on it first before doing this.Maybe there's an easier way, the remote callback could be called differently as there's only 1 instead of refactoring all local validators to use callbacks. But this obviously breaks the .all() function.I'm gonna spend a bit more time on it I'll update this ticket in a bit.
The text was updated successfully, but these errors were encountered: