Wednesday, 15 July 2015

How to hookup jQuery autocomplete with POST query to remote data source? -



How to hookup jQuery autocomplete with POST query to remote data source? -

i'm trying hook text field jquery ui's autocomplete remote info source using post query. far have this:

$( "#booking_student" ).autocomplete({ source: function( request, respond ) { $.post( "/path/to/my/api.php", { student: request.term }, function( response ) { //do } ); } });

using firebug can see api returning results i'd expect, autocomplete dropdown doesn't appear. need plug results autocomplete dropdown? need populate variable in //do section json results or?

you need supply results respond callback widget giving you:

$( "#booking_student" ).autocomplete({ source: function( request, respond ) { $.post( "/path/to/my/api.php", { student: request.term }, function( response ) { respond(response); }); } });

this of course of study assumes info array items containing either label property, value property, or both. outlined in documentation source option.

jquery jquery-ui autocomplete jquery-autocomplete jquery-ui-autocomplete

No comments:

Post a Comment