views:

16

answers:

1

I am attempting to clone the functionality of google suggest. I have found google urls that return the the suggestions via json (google.com/complete/search?q=abc)

I am already using jquery, so i would prefer to use code similar to this for the auto-complete http://docs.jquery.com/UI/Autocomplete

the code that is lacking is the ajax to request the suggestions, and tie back into the jquery auto complete.

can someone tell me the general approach i should take? or point me to a similar example?

A: 

i think most people will use $.ajax to make a request. I think it's require too many parameter. Most of the time, i use $().load(). if u run on aspx u might want to try generic handle.

$("input#autocomplete").keypress(funciton(){
 var input = $(this);
 input.load("google.com/complete/search?q=" + escape(input.val()), function(response, status, xml){
  var json = eval(response); // or eval("[" + response + "]")
  input.autocomplete({source: json });
 });
});
888
good try. this makes sense, but it doesn't run... function is misspelled. not sure what else... doesn't generate error, just doesn't work for me.
Andrew Thomas