我的 jquery 代码来获取名称、代码和类别:
$(req.responseText).find("Table").each(function(i) {
var item = $(this),
name = item.find('Name').text(),
code = item.find('Code').text(),
catg = item.find('Category').text();
var $content = $('<li><a href="#"><img src="../../img/album-bb.jpg"><h3>Name: '+ name + '</h3><p>Code: '+ code + '</p><p>Category: '+ catg + '</p></a><a href="#purchase" data-rel="popup" data-position-to="window" data-transition="pop">Add to favorites</a></li>');
$('#RecipeList').append($content).listview('refresh');
});
这是我的 XML 的示例响应:
<Table diffgr:id="Table1" msdata:rowOrder="0">
<Code>106377</Code>
<Name>Blackened red snapper</Name>
<Category>123</Category>
<Yield>4</Yield>
<YieldUnit/>
</Table>
<Table diffgr:id="Table2" msdata:rowOrder="1">
<Code>303570</Code>
<Name>Celery soup</Name>
<Category>123</Category>
<Yield>1</Yield>
<YieldUnit/>
</Table>
<Table diffgr:id="Table3" msdata:rowOrder="2">
<Code>303675</Code>
<Name>Challah French Toast</Name>
<Category>123</Category>
<Yield>6</Yield>
<YieldUnit/>
</Table>
listview 输出是这样的:
Name: Blackened red snapperCelerySoupChallah French toast
Code: 106377303570303675
Category: 123123123
如何放入不同的列表视图?..当它追加时。谢谢