Jquery autocomplete with remote datasource with cache

i’m using jquery autocomplete function with remote datasource with caching. But i can only work it with a local source php file. if i put the php on another domain, autocomplete script stops working.
i have spent many hours for googling and trying, but no luck :slight_smile:

my autocomplete jquery is just the same at jqueryui.com:

$(function() {
    var cache = {},
        lastXhr;
    $( "#searchbox" ).autocomplete({
        minLength: 2,
        source: function( request, response ) {
            var term = request.term;
            if ( term in cache ) {
                response( cache[ term ] );
                return;
            }
            lastXhr = $.getJSON( "http://example.com/source.php", request, function( data, status, xhr ) {
                cache[ term ] = data;
                if ( xhr === lastXhr ) {
                    response( data );
                }
            });
        }
    });
});

and an example output of source php file is:

[“bird”,“cat”,“dog”,“fox”]

i know i need to put ?callback=? to the source url and echo $_GET[‘callback’] to the php file but i couldn’t make it work! :goof: how can i achive remote domain autocomplete with caching? there is no answer of this question around :slight_smile: and this will help many people i think.
please tell me what to do in php and jquery?