I am trying to change the “term” field that is set to that by default with the jquery ui autocomplete feature. Is it possibly to easily change it to “q” (query) without going and changing it in the “core” file?
JavaScript:
<script>
$(function() {
$( "#spotify_song_search" ).autocomplete({
source: "http://ws.spotify.com/search/1/track.json",
data: {
q: request.term
},
dataType: "getjson",
minLength: 3,
select: function( event, ui ) {
alert('select');
}
});
});
</script>
Yes, it’s possible by making your own AJAX request.
Assume you have the following setup:
Autocomplete by default (as you noticed) sends requests that look like:
You can supply a function reference to the
sourceoption of autocomplete. Inside that function you can make your own AJAX request, which would look like this:This should generate a request looking more like: