This is a snippet from my coding project.
function getStudentList() {
$.getJSON('http://mydomain.com/getStudents.php?jsoncallback=?', function(data) {
$('#studentList li').remove();
$('#load').hide();
$.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');
});
}
I have heard that PhoneGap may not support URL formats like student_detail.html?user_name=XXXX. Therefore, I am considering using localStorage for storing the selected student's details. Is this a valid approach? How can I save the value of the chosen student's username?
var id = $("#id").val();
window.localStorage["id"] = id;
I'm unsure how to create a specific #id inside $.each loop.