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

$.Ajax call for multiple groups from separate sources, if a single source fails, typeahead remains in fetching data view #401

Closed
mistyn8 opened this Issue Dec 19, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@mistyn8

mistyn8 commented Dec 19, 2017

$.Ajax call for multiple groups from separate sources, if a single source fails, typeahead remains in fetching data view

So I have a need to fetch data for 3 groups, 2 of those are a local call so combined into a single request.
The third group is from an external source.

If the external source fails. (returns a 404) then the spinning loading view continues. If I comment out

  // #248, #303 Aborted requests would call populate with invalid data
  //if (typeof jqXHR !== "object") return;

Then it works as expected displaying the local data and gracefully ignoring the failed external call.

I have noticed with some console logging that even though it might be the same call to a non existant external endpoint (to mimic failure) sometimes (typeof jqXHR !== "object") is false other times true.. so seems inconsistent.

I wonder if the distinction here could be between an aborted request rather than a failed request?

I suppose I could workaround this with combining the sources externally, but thought I'd report anyway.

PS: great job ;-)

@raulvc

This comment has been minimized.

raulvc commented May 14, 2018

I can confirm this is still true

raulvc pushed a commit to raulvc/jquery-typeahead that referenced this issue May 14, 2018

@running-coder running-coder added the Bug label Jul 20, 2018

@running-coder

This comment has been minimized.

Owner

running-coder commented Jul 20, 2018

Hey @mistyn8 gj for debugging it out, you figured out the right line! Althrough this is needed but only for aborted request let me explain. If the first request is sent and a subsequent request is set before the first one(s) finishes typeahead will think that the first request is still valid and populate the data from it. Instead what we want to do is return an do nothing for aborted requests and only consider the latest requests as the source of truth. I've modified the condition to also include "error" type of requests (don't know why I haven't caught this before...) so Typeahead is populated correctly if 1 or multiple requests fails but at least 1 succeeds.

if (textStatus === 'abort') return;

running-coder added a commit that referenced this issue Jul 20, 2018

Fix #401 $.Ajax call for multiple groups from separate sources, if a …
…single source fails, typeahead remains in fetching data view

@running-coder running-coder added this to the 2.10.6 milestone Jul 20, 2018

@running-coder

This comment has been minimized.

Owner

running-coder commented Jul 20, 2018

I've put the fix on the develop branch, let me know if it works 👍

running-coder added a commit that referenced this issue Jul 30, 2018

Version 2.10.6
Fixes
- Fix #401 $.Ajax call for multiple groups from separate sources, if a single source fails, typeahead remains in fetching data view
- Fix #438 Too many ajax calls with multiple groups

running-coder added a commit that referenced this issue Nov 28, 2018

Version 2.10.6
Fixes
- Fix #401 $.Ajax call for multiple groups from separate sources, if a single source fails, typeahead remains in fetching data view
- Fix #438 Too many ajax calls with multiple groups
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment