I am trying update the global variable from the response I get. I know my scopes are messed up somehow and I tried finding an example but couldn't find one that matched this. I'm new at javascript so any syntax tips would help as well. Any help would be great!
hit_count: function(permalink) {
var count = 0,
perm = permalink,
url;
if(perm) {
url = 'http://www.mysite.com?q=scope:' + perm + '&callback=?';
$.getJSON(url, function(result){
count = result.count;
//want this to update global count or at least return this count
if(count > 1) {
count = count - 1;
}
});
}
return count;
}
$.getJSONis asynchronous so this won't work. When you doreturn count,$.getJSONmight not be done yet. Can you show us how you use the function.