setting jQuery .data() within .getJSON callback
- by hackmaster.a
I'm doing a couple of .getJSON calls and if any one of them succeeds, I'm trying to set a bool to true so I can then do some other stuff elsewhere on the page. I was trying to use jquery's .data() function, but I don't seem able to set it from inside the .getJSON callback. for example:
$('#citations_button').data('citations', false);
$.getJSON(apaurl, function(data) {
$('#apacite').html("<td class=\"bibInfoLabel\">APA Citation</td><td class=\"bibInfoData\">"+data+"</td>");
$('#citations_button').data('citations', true);
}, "html");
// other .getJSONs look like above...
console.log("citations? "+$('#citations_button').data('citations'));
prints false, even when I know the data came through. I thought this would work since .data() uses the cache to store the key/value pair. how can i flag successes?? appreciate any assistance!!