Javascript 表达式“$.mobile”[undefined]的结果不是对象
我是jquery mobile的新手,我使用jquery mobile和phoneGap以及localstorage Html开发了一个移动应用程序,我想在page.Html中保存一个输入值,然后我将使用localstorage.getitem检索该值并在URL中使用,当我添加此行值=localstorage.getitem'myStorage'时我的问题;我无法连接到我的应用程序,出现以下错误: 表达式“$.mobile”[undefined]的结果不是对象。在 file:///android_asset/www/js/application.js:258 这是我保存输入值的应用程序 application.jsJavascript 表达式“$.mobile”[undefined]的结果不是对象,javascript,html,jquery-mobile,cordova,local-storage,Javascript,Html,Jquery Mobile,Cordova,Local Storage,我是jquery mobile的新手,我使用jquery mobile和phoneGap以及localstorage Html开发了一个移动应用程序,我想在page.Html中保存一个输入值,然后我将使用localstorage.getitem检索该值并在URL中使用,当我添加此行值=localstorage.getitem'myStorage'时我的问题;我无法连接到我的应用程序,出现以下错误: 表达式“$.mobile”[undefined]的结果不是对象。在 file:///android
function setMessage() {
var firstName=document.getElementById('addresseip');
alert("Hello " + firstName.value + ", hope you like JavaScript functions!")
localStorage.setItem('myStorage', firstName.value);
}
这是我在同一个page.js中对这个值的调用,输入值是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
你能帮帮我吗,
谢谢因为$.mobile没有定义,我猜jquery移动库没有加载。在调用showUser之前,请检查是否已加载jquery和jquery mobile。除了加载jquery,还应包括jQM。还要确保使用jQM的代码包含在它后面
<script src="//code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
<script src="yourscripts.js"></script>
或
感谢您的回复,但我不明白我是如何加载jquery和jquery mobile的,在我的include中是这样的,否则我必须使用另一种方法这一行加载jquery。对于jquery mobile,您可以在文档中找到答案,例如:>Docs>Quick start guide。
<script src="//code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
<script>
/* Your code here */
</script>