我是jquery mobile的新手,我開發了一個包含jquery mobile和phoneGap和localstorage Html的移動應用程序,我想在頁面中保存一個輸入值html的,然後我會再檢索該值withlocalstorage.getitem和網址中使用,我的問題,當我加入這行value=localStorage.getItem('myStorage');
我無法連接到我的應用程序,我得到這個錯誤:
表達的結果「 $ .mobile'[undefined]不是一個對象。在 文件:///android_asset/www/js/application.js:258
這是我保存的輸入值 的application.js
function setMessage() {
var firstName=document.getElementById('addresseip');
alert("Hello " + firstName.value + ", hope you like JavaScript functions!")
localStorage.setItem('myStorage', firstName.value);
}
的應用,這是我的呼籲在同一個頁面的.js此值,輸入vaule是param.html並調用這個值是index.html中:
function showUser(){
value=localStorage.getItem('myStorage');
val1 = document.getElementById("name").value;
val2 = document.getElementById("pass").value;
if (val1=="")
{
showdialog("Verifiez login et mot de passe","Erreur");
}
else{
alert("test"+value);
$.mobile.showPageLoadingMsg();
var geturl;
geturl = $.ajax({
url:"https://"+value+":80/B/authenticate",
//url:"https://10.0.2.2:80/B/authenticate",
dataType:"json",
timeout:10000000,
cache:false,
type:'GET',
beforeSend : function(req) {
req.setRequestHeader('Authorization',
make_base_auth (val1, val2));
},
error:function(XMLHttpRequest,textStatus, errorThrown) {
$.mobile.hidePageLoadingMsg();
showdialog("Verifiez login et mot de passe","Erreur");
},
success:function(results) {
if(results==true){
$.mobile.changePage("bienvenu.html","fade");
$.mobile.hidePageLoadingMsg();
}
我的錯誤是一個線$ .mobile.showPageLoadingMsg();
你能幫幫我,謝謝
感謝您的答覆,但我不understing我如何加載jQuery和jQuery Mobile的,我有這樣的'<腳本類型= 「文/ JavaScript的」 SRC = 「http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js」>',或者我必須使用其他方法 – julia
這行加載jquery。對於jQuery的移動,你會在文檔中找到答案,請參閱例如:http://jquerymobile.com/>文檔>快速入門指南。 – Claude