getting error when trying to use ajax with select2

36 views
Skip to first unread message

select3

unread,
Nov 10, 2016, 9:53:08 PM11/10/16
to select2

Any idea how to debug the ajax funtionality of select2? Here's an example of what I'm trying to implement: https://jsbin.com/sohupoviko/edit?html,output and here's the result set for http://localhost:4000/users:

[
  {
    "id": 1,
    "first_name": "John",
    "last_name": "Smith"
  },
  {
    "id": 2,
    "first_name": "John2",
    "last_name": "Smith2"
  }
]

This is the local error being returned when I run the code locally:

jquery.min.js:2 jQuery.Deferred exception: Cannot read property 'length' of undefined TypeError: Cannot read property 'length' of undefined
    at d (https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js:2:5214)
    at Object.f.transport.d.status.0.d.status.e.trigger.message (https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js:2:4227)
    at j (http://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js:2:29948)
    at k (http://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js:2:30262) undefined

Any idea what the root cause might be or how to debug?

Reply all
Reply to author
Forward
0 new messages