I'm trying to use the Autocomplete plugin in jQuery to allow a user to search for a person's name quickly using a text field and return their Facebook user id. The JSON that Facebook provides is along these lines:
{
"data":[
{
"name":"Emma Alexander",
"id":"8110855"
},
{
"name":"Dave Suckow",
"id":"19546358"
},
{
"name":"Jessica Willits",
"id":"45734687"
}
]
}
However, I'd like to do the searching locally, rather than retrieving Facebook JSON every time, so I think I need to copy all of the names and IDs into a local JavaScript Object (I think that's the best way to do it?) and then use jQuery to search through those names instead. When the user selects a name from the text field, it will call another function and pass it the selected person's Facebook ID.
However, I'm not sure if this is the best way, or how I would really go about implementing it.
If anybody could offer a couple of small code examples, especially for copying the data from Facebook's JSON to a local Javascript object and then searching through that object, it would be massively appreciated! :)
Thanks a lot