Need help understanding how jQuery autocomplete script works

Dear fellow web developers:

I am a junior web developer, and I found the following autocomplete script online that uses jQuery, and PHP:

I like it very much (the facebook script in particular), and I am trying to reverse engineer it to understand how it works (not the jquery file, but the html and php code).  However, I'm a little confused as to how this is working because on the one hand I see the list of tv shows listed inside the code of demo.html, but the items in the menu that drop down, don't reflect those values, so these values are clearly coming from someplace else.  Can someone please explain to me how this script functions using the php file that it works with?

Thanks in advance to all who reply.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Inside demo.html go to line 62, you'll see this piece of code
        <script type="text/javascript">
        $(document).ready(function() {
            $("#demo-input-facebook-theme").tokenInput("", {
                theme: "facebook"

Open in new window

Now if you go to, you'll see the list of show json encoded. So if you want to implement it on your own site, you'll have to do something very similar, which is actually explained in the Installation and setup on the very link you posted

Create a server-side script (PHP, Rails,, etc) to generate your search results. The script can fetch data from wherever you like, for example a database or a hardcoded list. Your script must accept a GET parameter named q which will contain the term to search for. E.g.

Your script should output JSON search results in the following format:

    {"id":"1035","name":"Desperate Housewives"},

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fsyedAuthor Commented:
Thanks very much for your help!

Take care.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.