そのため、innerHTMLを使用して一連のjson結果を取得してdivタグ内に表示しようとしています。
<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>
私の問題は、変数thread.Titleは完全に機能しますが、変数thread_idは、最初にURLに移動して正しいURLを見つけたときにのみ機能しますが、2回目はすべてのスレッドの後に同じIDを表示します。このような:
<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>