【开源中国 APP 全新上线】“动弹” 回归、集成大模型对话、畅读技术报告”
我是在一个http://169.254.8.114:8080/my/loginregist/login.html页面做的登陆,采用的是
jQuery(document).ready(function() { //输入事件 $("input[id]").bind("focus",function () { if($(this).attr("id")=='username'||$(this).attr("id")=='password') $(this).attr("value",""); }); //提交 $("#submit").bind("click", function() { if (valid()) { $.ajax({ type: "POST", url: "/my/servlet/LoginServlet", data: $("form#loginform").serialize(), success: function(msg){ if(msg=='success'){ $.mobile.changePage("../index/index.html","slide",false,true); }else{ $.mobile.changePage("../message.html","slide", true, false); } } }); } }); });
提交方式,但是,通过servlet在跳转到index.html之后,url显示的是http://169.254.8.114:8080/my/loginregist/login.html#../index/index.html,这样的话我在index.html中的滑动效果还有页面内的page跳转都跳不过去,但是直接进入http://169.254.8.114:8080/my/index/index.html这个页面后一切正常,谁能告诉我怎么解决url的问题啊
找到强人的解释了:
看http://javafansmagic.iteye.com/blog/1097511
其实不管页面内链接还是页面间切换,jQuery Mobile都是发起Ajax请求加载新的页面。如果想链接到一个新界面,而且URL中不想有以前路径#新页面,可以通过在加入链接属性rel="external"或data-ajax="false",这就告诉jQuery Mobile需要重新加载一个新的页面,而且URL也是全新的。
这样 $(function(){}) 中的方法会执行
恩,我用最新的还是有这个问题的,所以导致无法执行$(function(){ })中的方法
引用来自“红薯”的答案