gpt4 book ai didi

jquery - 将 Json append 到 div

转载 作者:行者123 更新时间:2023-12-01 06:49:14 26 4
gpt4 key购买 nike

您好,我有 json 格式的结果,我想将其 append 到 html div 中。 json 看起来像:

jsonp1373893536648([{
"MAXCHILDREN": 1,
"PICTURE": "3AE30747-0956-0F6C-F6F4D6FC13243BDF.jpg",
"MAXPERSONS": 3,
"RATEINCLUDE": 2,
}, {
"MAXCHILDREN": 1,
"PICTURE": "3AF1F0ED-01DC-32C8-C663F39A1B430F89.jpg",
"MAXPERSONS": 3,
"RATEINCLUDE": 2,
}, {
"MAXCHILDREN": 3,
"PICTURE": "3AF6A412-CB40-3B77-C777273F5378345A.jpg",
"MAXPERSONS": 3,
"RATEINCLUDE": 2,
}, {
"MAXCHILDREN": 1,
"PICTURE": "3AFC9046-92F4-DBB7-93E5D7EF8A9AB831.jpg",
"MAXPERSONS": 3,
"RATEINCLUDE": 2,
}])

现在我需要做这样的事情:

jQuery(response_container).append('<div class="maxchildren">MAXCHILDREN: ' + MAXCHILDREN + '</div>');
jQuery(response_container).append('<div class="pic">PICTURE: ' + PICTURE+ '</div>'); ...

对于每个 MAXCHILDREN、PICTURE、MAXPERSONS、RATEINCLUDE。请帮忙???

最佳答案

尝试一下,假设数据是您正在谈论的响应:

var a = data, b = 0;

while( b < a.length ){

$('<div/>',{

'class' : 'maxchildren',
'text' : 'MAXCHILDREN: ' + a[ b ].MAXCHILDREN

}).appendTo( response_container );

$('<div/>',{

'class' : 'pic',
'text' : 'PICTURE: ' + a[ b ].PICTURE

}).appendTo( response_container );

b++;
}

关于jquery - 将 Json append 到 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17669921/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com