嗨im從數據庫中使用JSON和ajax檢索一些數據。當我抓住我需要的信息時,我希望它顯示在div中的新行中,即時消息將它放入。在新行上顯示JSON結果AJAX
當時郵政編碼只是覆蓋彼此。
$.ajax({
url: 'process.php',
type: 'GET',
data: 'address='+ criterion,
dataType: 'json',
success: function(data)
{
jQuery.each(data, function()
{
$('#carParkResults').html("Postcode " + data[count].postcode);
codeAddress(data[count].postcode);
alert(count);
count++;
});
},
error: function(e)
{
//called when there is an error
console.log(e.message);
alert("error");
}
});
您可以爲每個郵政編碼創建一個新的'div'並將其追加。您還可以簡化您的'each'循環,查看文檔:http://api.jquery.com/jQuery.each/。 –