表达式 '$.mobile' [未定义] 的结果不是对象
Result of expression '$.mobile' [undefined] is not an object
我是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>
由于$.mobile
是undefined
,我猜jquery移动库没有加载。在调用 showUser()
之前,请检查您是否已加载 jquery 和 jquery 移动版。
相关文章:
- 对象拟合:获取结果尺寸
- JSON.stringify和Object.keys在同一个对象上产生不同的结果
- JQuery Deferred Ajax,将结果保存在调用对象中
- 在页面对象文件中验证sendKeys结果会导致未定义的错误(Protractor)
- 返回带有筛选结果的新JSON对象
- 为什么纬度结果对象从谷歌地图 API 更改
- 当我运行代码时,我得到以下结果 []对象对象] [对象对象],但应该给我一个有序数组
- 为什么脚本 Db 查询结果对象不同
- 获取 FileReader() 的结果对象
- 从 Webix 中结果对象的属性加载数据
- 如何在函数中返回结果对象
- 如何在对象数组中循环Json结果对象
- 将FileReader内部的结果对象分配给变量
- JS不给出任何结果(对象)
- 在带有填充嵌套数组的mongoDB文档中查找并构建新的结果对象
- 敲出$parent点击click事件很好,但是结果对象的属性没有定义
- 更正JSON结果对象
- 将查询结果对象传递给单独的函数
- 从结果对象数组中获取一个值
- JSON响应的问题,结果对象的属性被读取为未定义,但我可以看到它存在