我不知道如何在Stackoverflow中搜索這個問題,它給出了不同的解決方案,並且不涉及我的問題。所以我會再次需要你的幫助。可變obj的
值:
item.title = Title1 and Title2
item.description = Description1 and Description2
HTML文件:
function test_pop() {
var fb_id = "xxxxxxxxxxxx";
var v_id = "xxxxxxxx";
$.post('http://mysite.com/myfile.php', {fb_id: fb_id, v_id: v_id}, function(data) {
var obj = $.parseJSON(data);
$.each(obj,function(index, item){
achievement = "You Obtained " + item.title + " " + item.description;
achievement_pop(achievement);
});
});
}
achievement_pop功能:
function achievement_pop(data) {
$("#achievement_popup").html(data).show(); //DIV that should show up
}
所以,問題是,當DIV顯示出來,它只輸出:
<div> <!-- Imagine that this content is inside a DIV -->
**You Obtained Title2 Description2**
</div>
但我的願望輸出爲:
<div> <!-- Imagine that this content is inside a DIV -->
**You Obtained Title1 Description1**
**You Obtained Title2 Description2**
</div>
希望你們幫幫我,謝謝。
它工作正常!感謝您的回答,我很感激! :) –