Okay, I sorted out the previous problem and can get data from the Python backend to the browser via the Autocomplete plugin. But, the test data:
data = ["string 1", "string 2", "string 3", "string 4", "string 5"] ... displays as one string item ie.: ["string 1", "string 2", "string 3", "string 4", "string 5"] ... including the square brackets! ... instead of one string per line ie.: "string 1" "string 2" ... "string 5" I'm using Python's simplejson to get data to Autocomplete ie.: def GET(self): result = simplejson.dumps(data) print result The js file is: $().ready(function() { function findValueCallback(event, data, formatted) { $("<li>").html( !data ? "No match!" : "Selected: " + formatted).appendTo("#results"); } function formatItem(row) { return row[0] + " (<strong>id: " + row[1] + "</strong>)"; } function formatResult(row) { return row[0].replace(/(<.+?>)/gi, ''); } $("#suggest").autocomplete("/act"); }); Any ideas? Cheers! Dinesh On Apr 7, 12:31 pm, dineshv <[EMAIL PROTECTED]> wrote: > Sorry, that first error should have said: > > > 404 -http://127.0.0.1:8080/act?q=a&limit=150 > > Jorn / Shawn > > In my act.js, I have: > > > $("#suggest").autocomplete("/act"); > > The act.html file displays with the input box. When I enter, for > example 'a', the following error appears: > > >http://127.0.0.1:8080/act?q=a&limit=150 > > and > > > line 2723 > > inhttp://127.0.0.1:8080/static/js/jquery-autocomplete/lib/jquery.js > > Any idea what's going on? > > Dinesh > > On Apr 7, 12:27 pm, dineshv <[EMAIL PROTECTED]> wrote: > > > Jorn / Shawn > > > In my act.js, I have: > > > > $("#suggest").autocomplete("/act"); > > > The act.html file displays with the input box. When I enter, for > > example 'a', the following error appears: > > > >http://127.0.0.1:8080/act?q=a&limit=150 > > > and > > > > line 2723 > > > inhttp://127.0.0.1:8080/static/js/jquery-autocomplete/lib/jquery.js > > > Any idea what's going on? > > > Dinesh > > > On Apr 6, 11:09 am, Ashley <[EMAIL PROTECTED]> wrote: > > > > This is possible but a bit difficult with the plugin. I wish it were > > > easier as I don't think there is yet a jQuery autocomplete that > > > competes with those from other packages like YUI. > > > > You have to override the 'parse' and 'formatItem' functions. Here is > > > an example of it that I'm using. > > > > var autocompleteJSON = function(raw) { > > > varjson= typeof(raw) === "array" ? raw : raw.resultSet; > > > var parsed = []; > > > for (var i=0; i <json.length; i++) { > > > var row =json[i]; > > > parsed.push({ > > > data: row, > > > value: row["title"] + ' [' + row["id"] + ']', > > > result: row["title"] > > > }); > > > } > > > return parsed; > > > }; > > > > $("input[name='parent_autocomplete']").result(function(event, data, > > > formatted){ > > > $("input[name='parent']").val(data["id"]); > > > }); > > > > $("input[name='parent_autocomplete']") > > > .autocomplete("/cat/admin/page/search", > > > { width: "inherit" > > > ,minChars:3 > > > ,extraParams: {"id":6 } > > > ,max: 25 > > > ,delay: 900 > > > ,dataType: "json" > > > ,parse: autocompleteJSON > > > ,formatItem: function(row) { return row["title"] } > > > ,mustMatch: true > > > ,selectFirst: false > > > }); > > > > Where theJSONcoming back from the server looks like: > > > > {"resultSet":[{"id":"3","title":"Green Services"}, > > > {"id":"5","title":"Green Living Guides"}]} > > > > You can match up the format against the autocompleteJSON parsing > > > function to see what's going on. > > > > It's always best to wrap yourJSONin an object {} and not just an > > > array []. In an array the data can be visible to hacking on certain > > > browsers (just FF, I think). > > > > J-Ashley