So I am trying to get a series of json results to present itself within a div tag using innerHTML.
<script>
$(document).ready(function() {
var html2 = '';
var thread_id = '';
var created_thread_ids = new Array(123123, 12312312, 1231222);
for (var i in created_thread_ids)
{
thread_id = created_thread_ids[i];
$.getJSON(ravenUrl + '/docs/threads/' + thread_id, function(thread){
html2 += '<div class="result">' + thread.Title + thread_id + '</div>';
document.getElementById("showit").innerHTML = html2;
});
}
});
</script>
<div id="showit"></div>
My problem is that the variable thread.Title works perfectly but the variable thread_id only works in the first time when it goes to the url and finds the right url but the second time it shows the same id after every thread. Like this:
<div id="showit">
<div class="result">This is the first title123123</div>
<div class="result">This is the second title123123</div>
<div class="result">This is the third title123123</div>
</div>