I have this code:
$('#find').click(function(){
if(first.val() != '' && second.val() != ''){
$.getJSON(urlPersonSearch + first.val() + "?callback=?", function(json) {
firstId = (json[0].id != undefined) ? json[0].id : '';
if(firstId != '') result = grabMovies(firstId);
var i = result[0].filmography.length;
while(i--){
movies[result[0].filmography[i].id] = result[0].filmography[i].name;
}
});
$.getJSON(urlPersonSearch + second.val() + "?callback=?", function(json) {
secondId = (json[0].id != undefined) ? json[0].id : '';
if(secondId != '') result = grabMovies(secondId);
var i = result[0].filmography.length;
while(i--){
movies[result[0].filmography[i].id] = result[0].filmography[i].name;
}
});
}
});
function grabMovies(id){
$.getJSON(urlPersonResult + id + "?callback=?", function(json) {
return json;
});
}
Now, what I'm trying to do, is end up with an object with ID and Movie Name as the key/value. Ultimately i'm trying to get an object which contains only the matches between the two json results. Ie.
if the first had a result of
23 = hello, 283 = goodbye,
and the second had a result of
23 = hello, 294 = bye
I would end up with an object of
23 = hello
Has anyone got any advice on how to do this?