-1
Hej家伙,我在FileZilla和Safari中使本地存储工作有问题,它在谷歌浏览器(通常是:D)非常好用。按下按钮时,它不会将任何内容保存到本地存储中。你有一些提示,我应该添加或改变?谢谢本地存储不工作在FileZilla和Safari
$(document).ready(function() {
$(".logInAsAdmin").click(function(){
var jStudent = {};
jStudent.userSingUpNameLS = "Admin";
jStudent.userLastNameLS= "Tivoli2016";
console.log(jStudent);
var sStudentsFromLocalStorage = localStorage.sajStudents;
console.log(sStudentsFromLocalStorage);
var aStudents = getDataFromLocalStorageAsObject();
aStudents.push(jStudent);
// console.log(aStudents);
// convert the array into a string
var sFinal = JSON.stringify(aStudents);
console.log(sFinal);
localStorage.sajStudents = sFinal;
$(".myModal").modal('show');
//e.preventDefault();
});
function getDataFromLocalStorageAsObject(){
try{
return JSON.parse(localStorage.sajStudents);
}
catch(e){
return [];
}
}
});