jQuery-tokeninput not showing my search results -


i using jquery-tokeninput , not able work, ajax call not entering success method when result contains list of results.

i use jquery version 1.9.1 , tokeninput version 1.6.1

i using html, , jquery script:

<input type="text" class="selector" name="users">  $('.selector').tokeninput("/event/usersearch", { method: 'post', minchars: 2 }); 

when test following response:

click on edit field provide focus.

  • a dropdown shown text "type in search term"

press letter u.

  • the dropdown disappears expected set search after chars

press letter p.

  • the dropdown comes text "searching..."
  • a request sent server query string "up"
  • the server respond (content-type: application/json;charset=utf-8)(55 bytes):

    [{id:2, name:'superuser'},{id:3, name:'bo superduper'}]

    but dropdown still showing "searching..."

press letter x

  • a request set server query string "upx"
  • the server responds with(2 bytes): []
  • the dropdown changes "no results"

so when server return empty list works fine, if records returned userinterface not showing items.

i tried both , post requests...

i tried return [{id:2, name:"superuser"},{id:3, name:"bo superduper"}] same result

i tried return [{id:"2", name:"superuser"},{id:"3", name:"bo superduper"}] same result

i tried return [{"id":"2", "name":"superuser"},{"id":"3", "name":"bo superduper"}] same result

within tokeninput java script file, set breakpoint @ first line in ajax success function:

// attach success callback ajax_params.success = function(results) { cache.add(cache_key, $(input).data("settings").jsoncontainer ? results[$(input).data("settings").jsoncontainer] : results); 

and not called on requests contains items, requests returns empty lists called. explains why "searching..." remains on, , changes when empty lists returned.

all requests return http status 200 ok.

from byte count utf-8 same ascii, shouldnt encoding problem...

so ajax request sent, , returns success method not called?

how returning json? if ajax call isn't calling success i'd guess response somehow malformed. example, of 4 versions you've tried - last 1 valid. json requires double quotes, , attribute names in quotes.

i'd suggest automatically generating json string @ source, should ensure correct header types , too. if it's php, can use:

echo json_encode(//php assoc array here);


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -