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

jqXHR.abort considered harmful #11

Merged
merged 1 commit into from
Sep 21, 2015
Merged

Conversation

dsanders11
Copy link
Contributor

As per the request in #3 for a PR. Avoid using abort unless the jqXHR hasn't been sent to avoid a closed connection (and broken pipe on the server).

this.xhr = false;
} else {
// Ignore response from earlier request.
return;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A future improvement here would be to not ignore the response, since it's a valid response. If every XHR gets an increasing ID attached to it and the autocomplete keeps track of the last displayed ID, then results from earlier could be safely displayed to the user as they type. The xhr-pending class would remain on the input until the current request finished, making it clear that the results are not final.

This would be nice behavior in situations where the server response time is longer than xhrWait value. If the server takes 400ms to get a response to the client, and xhrWait is 200ms, then some XHR will be sent while the user is typing and get a response before the most recent request finishes, so it could be displayed as the user types.

jpic added a commit that referenced this pull request Sep 21, 2015
jqXHR.abort considered harmful
@jpic jpic merged commit b12f945 into yourlabs:master Sep 21, 2015
@aidanlister
Copy link
Contributor

Sounds great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants