Hi friends,

I am new in jQuery. I ran a jQuery Autocomplete example from the book Novice to Ninja at chapter 7. Please see the html, and javascript code below:

HTML code:

<div id="container">
<div id="header">
<div id="content">
<h2>Add a Celebrity</h2>
<form action="null" method="post">
<label for="name">Name/label>
<input type="text" id="name" />
<label for="location">Last known whereabouts/label>
<input type="text" id="location"/>
<input type="submit" value="Add!"/>
<div id="footer">
&copy; Copyright 2010 CelebriTracker Productions


var cities = ['Paris', 'New York', 'Milan', 'Stockholm', 'Melbourne', 'Montreal', 'Mexico', 'Los Angeles', 'San Francisco', 'London', 'Dubai', 'Madrid', 'Tokyo', 'Hong Kong', 'Sydney'];
autoFill: true,
selectFirst: true,
width: '240px'

It working fine with hardcode of javascript array of cities. However, when I change javascript array cities to my javaSevlet code. That is the line $('#location').autocomplete(cities,{ becomes $('#location').autocomplete(http://localhost:8080/mywebapp/ListCityServlet,{.
In my ListCityServlet.java, in doPost(), I just write out the list of string like this:

cities = "['Paris', 'New York', 'Milan', 'Stockholm', 'Melbourne', 'Montreal', 'Mexico', 'Los Angeles', 'San Francisco', 'London', 'Dubai', " + "
'Madrid', 'Tokyo', 'Hong Kong', 'Sydney']";

PrintWriter out = response.getWriter();
out.write( cities );

When I entered any single charater, for example "m" on the <input type="text" id="location"/>. It displays whole string below in the autocomplete window ['Paris', 'New York', 'Milan', 'Stockholm', 'Melbourne', 'Montreal', 'Mexico', 'Los Angeles', 'San Francisco', 'London', 'Dubai', 'Madrid', 'Tokyo', 'Hong Kong', 'Sydney']

instead of a list of columns of Milan, Melbourne, Montreal.

I understand that my javaservlet the right String since I do not know what kind of right format of String my javaservlet code must return.

Please help

Thanks a lot for any of your comments and advices,