嗨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/。 –