bij*_*jin 0 jquery json asynchronous jquery-callback jquery-mobile
我想通过$.getJSON调用填充表格:
$.getJSON("localhost/url",
function (data) {
$.each(data.reporting_list.reporting, function (i, item) {
rows = '<tr><td>' + item.data1 + '</td><td>' + item.data2 + '</td></tr>'
});
$('#aaa').append(rows);
});
Run Code Online (Sandbox Code Playgroud)
填充后我想激活一些页面更改:
$.mobile.changePage("#homePage");
Run Code Online (Sandbox Code Playgroud)
但页面在$.getJSON完成之前发生了变化.
我想在$.getJSON完成后更改页面并改为显示ajaxloader.
做
$.getJSON("localhost/url", function (data) {
$.each(data.reporting_list.reporting, function (i, item) {
rows = '<tr><td>' + item.data1 + '</td><td>' + item.data2 + '</td></tr>'
});
$('#aaa').append(rows);
//move to the page in the callback itself
$.mobile.changePage("#homePage");
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6736 次 |
| 最近记录: |