Autocomplete with a Database Source

This live example retrieves matching student names from a PHP/PDO backend as the user types. The backend returns JSON objects containing a display label and record value.

Suggestions come from the student database table.

Remote JSON Source Top ↑

$( "#t1" ).autocomplete({
    minLength: 1,

    source: function ( request, response ) {
        $.getJSON(
            "autocomplete-demo1-dtl.php",
            { term: request.term }
        )
        .done( response )
        .fail( function () {
            response( [] );
        } );
    }
});

jQuery UI already sends the typed term to source callbacks through request.term.

Backend Response Shape Top ↑

[
    {
        "label": "Alex John",
        "value": 6
    },
    {
        "label": "John Deo",
        "value": 1
    }
]

After selection, the next example loads the complete record.

Show record details after Autocomplete selection →

For a larger location/PIN-code dataset, continue to Autocomplete Search.





plus2net.com






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer