用户登录后,我将其用户名设置为HTML5 localstorage。我想将用户名设置到下一页的顶部工具栏中,但由于某种原因,它不会在changepage
之后更改文本。页面更改但文本未插入。我究竟做错了什么?jQuery Mobile:在更改页面后向ID添加文本
编辑
success: function(data) {
if(data.status == "success") {
$.mobile.changePage("inventory.html");
var username = localStorage.getItem('username');
$("#top_username").html(username);
};
if(data.status == "failed") {
alert('Incorrect Login Information');
};
}
编辑:
为什么不干脆:'$(“#top_username”)。html(username);'因为你的本地getItem已经存储在var'username'中 –
@roXon当我tran时,这是一个错误通过代码推荐 – cantaffordretail