的力值,這是我的編碼如何獲得的localStorage
function getStudentList() {
$.getJSON('http://mydomain.com/getStudents.php?jsoncallback=?', function(data) {
$('#studentList li').remove();
$('#load').hide();
//students = data.user_name;
$.each(data, function(index, student) {
$('#studentList').append('<li><a href="student_detail.html?user_name=' + student.data.user_name + '">' +
'<h4>' + student.data.user_name + '</h4>' +
'<p>' + student.data.role + '</p>' +
'</a></li>');
});
$('#studentList').listview('refresh');
});
}
我已經看到了一些帖子說的PhoneGap可能不支持像student_detail.html URL的一部分?USER_NAME = XXXX,是不是?因此,我想通過使用localStorage來改變方法。 studentList將生成一個學生名單,我想向用戶顯示所選學生的詳細信息。一旦學生被選中,他的用戶名將被存儲在localStorage中,並獲取其他頁面中的值以供進一步處理。下一次,當用戶想要看另一名學生時,該localStorage將首先被刪除,並創建新的。這種方法好嗎?而且,我的問題是如何保存所選學生用戶名的價值?
var id = $("#id").val();
window.localStorage["id"] = id;
我dunnno如何創建在$。每個
HTTP:/ /coenraets.org/blog/2011/10/sample-application-with-jquery-mobile-and-phonegap/通過引用這篇文章,我想知道他爲什麼可以使用URL像student_detail.html?user_name = XXXX? – HUNG 2013-03-17 22:30:25
如果您已正確設置項目,PhoneGap應該不會遇到訪問您描述的URL的問題。您是否已將getStudents.html和student_detail.html所在的域添加到PhoneGap項目域白名單? http://docs.phonegap.com/zh/2.3.0/guide_whitelist_index.md.html 此外,因爲這是一個PhoneGap項目,所以student_detail.html的鏈接必須是絕對URL,例如HTTP://mydomain.com/student_detail.html USER_NAME = ... – thefrontender 2013-03-17 23:05:13