How to pass additional parameters in jQuery UI Autocomplete

At the time of using jQuery UI Autocomplete in PHP, many times you need to pass additional parameters to an autoComplete call. Here is a simple way to pass extra parameters to the source URL. In that case, you need to define a callback function to the source option of autoComplete call. Also, you can pass multiple parameters using this approach. Your jQuery UI Autocomplete function would be like the following.

$(function() {
    $( "#skills" ).autocomplete({
        source: function(request, response) {
                { term:request.term, extraParams:$('#extra_param_field').val() }, 
        minLength: 2,
        select: function(event, ui){
            //On select action

In the source file, you can get the term and additional parameters using the $_GET variable.

$term $_GET['term'];
$extraVar $_GET['extraParams'];

1 Comment

  1. Adnan Said...

Leave a reply

CodexWorld Newsletter

Subscribe CodexWorld updates via email and get every new post delivered to your inbox.