Skip to content
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

Closed
morganchristiansson opened this issue Nov 22, 2011 · 8 comments
Closed

client_side_validations uses synchronous ajax #226

morganchristiansson opened this issue Nov 22, 2011 · 8 comments
Assignees
Milestone

Comments

@morganchristiansson
Copy link

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.

@morganchristiansson
Copy link
Author

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
commit: morganchristiansson@d7c7b3a

@morganchristiansson
Copy link
Author

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.

@morganchristiansson
Copy link
Author

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.

@robertdapice
Copy link

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.

@morganchristiansson
Copy link
Author

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.

@bcardarella
Copy link
Contributor

I'm sorry I let this go stale. I am very interested in picking up where this left off if anybody is interested.

@bcardarella
Copy link
Contributor

We need to use jQuery promises for the validators.

@tagliala
Copy link
Contributor

I would like to switch to promise-based validators

This was referenced Jan 20, 2017
tagliala added a commit that referenced this issue Jan 20, 2017
The Uniqueness middleware:
- Is insecure
- Is subject to brute force attacks
- Badly performs because of synchronous Ajax calling
- Did not work with mysql2 adapter

This commit also wipes the middleware

Close: #512 #597 #612 #659 #226
@tagliala tagliala added this to the 7.0.0 milestone Jan 20, 2017
tagliala added a commit that referenced this issue Jan 20, 2017
The Uniqueness middleware:
- Is insecure
- Is subject to brute force attacks
- Badly performs because of synchronous Ajax calling
- Did not work with mysql2 adapter

This commit also wipes the middleware

Close: #512 #597 #612 #659 #226
tagliala added a commit that referenced this issue Jan 20, 2017
The Uniqueness middleware:
- Is insecure
- Is subject to brute force attacks
- Badly performs because of synchronous Ajax calling
- Did not work with mysql2 adapter

This commit also wipes the middleware

Close: #226 #512 #597 #612 #659 #636
@tagliala tagliala self-assigned this Jan 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants