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

Fix error callback with custom transport #5981

Merged
merged 1 commit into from
Mar 4, 2021

Conversation

KrzysztofBogdan
Copy link
Contributor

@KrzysztofBogdan KrzysztofBogdan commented Feb 11, 2021

If custom transport does not return any object
then calling error callback would result in Uncaught TypeError: right-hand side of 'in' should be an object, got undefined.
This patch adds check if $request evaluates to something.

This pull request includes a

  • Bug fix

The following changes were made

  • Check if transport method returned data

If custom transport does not return any object 
then calling error callback would result in `Uncaught TypeError: right-hand side of 'in' should be an object, got undefined`.
This patch adds check if $request evaluates to something.
@KrzysztofBogdan
Copy link
Contributor Author

KrzysztofBogdan commented Feb 11, 2021

As documentation example shows in
https://select2.org/data-sources/ajax

This should work:

  ajax: {
    transport: function (params, success, failure) {
      var request = new AjaxRequest(params.url, params);
      request.on('success', success);
      request.on('failure', failure);
    }

but there will be error while calling failure callback

@kevin-brown kevin-brown merged commit 0a30b0b into select2:develop Mar 4, 2021
p8 pushed a commit to p8/select2 that referenced this pull request Jan 11, 2024
If custom transport does not return any object 
then calling error callback would result in `Uncaught TypeError: right-hand side of 'in' should be an object, got undefined`.
This patch adds check if $request evaluates to something.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants