Background
I have an array of data in a result object returned by an Ajax call. The data is as follows:
{ Name="User1 Name1", FirstName="User1", Id="005400000001234567", more...} { Name="User2 Name1", FirstName="User2", Id="005400000001234568", more...}
Where each element is as follows:
{ Id:"005400000001234567", Name:"User Name", FirstName:"User", LastName:"Name", Title:"Manager" }
Question
I want to get data either using Id (return of one user) or Header (return of an array of users). What would be the best way to do this using JavaScript or jQuery?
Example
Here is what I tried to do so far:
function GetAllUsers() { AllUsersById = new Object(); MyClass.MyAjaxMethod(function(result,event) { if(result) { j$(result).each(function(index,item) { AllUsersById[item.Id] = item; }); } }); }
The code I have above is great for indexing by id, but I'm not sure what to do for Title.
Additional Information
In addition, by the way, there are about 1000 entries , and I need it to be effective enough. (This is one of the reasons I get data right away when the document is ready. However, I am not an expert on JavaScript or jQuery performance. Let me know if you have a better way.)
Any ideas? Thanks in advance!