寻找起点。我正在为 JQM 页面获取数据(通过 json)。我需要能够编辑任何返回的结果字段并通过 .post json 更新数据库。
我的想法是遍历 json 数组,进行更改并返回 json 数组,我是否应该在初始加载中填充文本框,然后创建单独的数组?
$.getJSON('JSON_MDB.php',
function (data) {
// data is now JSON object instantiated from retrieved info
$.each( data, function ( i, val ) {
($('<div>')
.attr({
'data-role': 'collapsible',
'data-content-theme': 'c',
'data-collapsed': 'true',
'id': 'cResults'
})
.html('<h4>' + this.lastName + ', ' + this.firstName + '</h4><ul data-role="listview" data-filter="true" data-filter-placeholder="Search Choices..." data-inset="true" id="makecollapsibleul"><li>'
+ 'FDID: ' + this.FDID + '</li><li>'
+ 'Choice 1: ' + this.C1 + '</li><li>'
+ 'Choice 2: ' + this.C2 + '</li><li>'
+ 'Choice 3: ' + this.C3 + '</li><li>'
+ 'Choice 4: ' + this.C4 + '</li><li>'
+ 'Choice 5: ' + this.C5 + '</li><li>'
+ 'Choice 6: ' + this.C6 + '</li><li>'
+ 'IP: ' + this.IPADDRESS + '</li><li>'
+ 'Pick Date: ' + this.PICKDATE + '</li></ul>'
))
.appendTo('#primary');
$('#makecollapsible').collapsibleset().trigger('create');
$.mobile.hidePageLoadingMsg();
});
}
);
HTML:
<div data-role="page" id="main">
<div data-role="header">
<h1>MCFRSIT JSON DATA</h1>
</div><!-- /header -->
<div data-role="content">
<ul data-role="listview" id="outer-ul">
<li>
<div data-role="collapsible">
<h4>Submitted Choices</h4>
<ul data-role="listview" data-inset="true" data-filter="true" id="makecollapsible">
<!-- AJAX CONTENT -->
</ul>
</div>
</li>
</ul>
</div><!-- /content -->
<div data-role="footer">
</div>
</div><!-- /page -->