表达式 '$.mobile' [未定义] 的结果不是对象

Result of expression '$.mobile' [undefined] is not an object

本文关键字:结果 对象 mobile 表达式 未定义      更新时间:2023-09-26

我是jquery mobile的新手,我用jquery mobile和phoneGap和localstorage Html开发了一个移动应用程序,我想在page中保存一个输入值.html然后我将使用localstorage.getitem检索此值并在URL中使用,当我添加此行时我的问题value=localStorage.getItem('myStorage');我无法连接到我的应用程序,我收到此错误:

表达式 '$.mobile' [未定义] 的结果不是对象。 file:///android_asset/www/js/application.js:258

这是我保存输入值的应用程序应用.js

function setMessage() {
    var firstName=document.getElementById('addresseip');
    alert("Hello " + firstName.value + ", hope you like JavaScript functions!")
                    localStorage.setItem('myStorage', firstName.value);
}

这是我在同一页中对此值的调用 .js,输入 vaule 是一个参数.html对该值的调用在索引中.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();

你能帮帮我吗,谢谢

除了加载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>

<script src="//code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
<script>
    /* Your code here */
</script>

由于$.mobileundefined,我猜jquery移动库没有加载。在调用 showUser() 之前,请检查您是否已加载 jquery 和 jquery 移动版。