Jquery mobile 奇怪的cflocation行为:重定向到页面但不更新url
我在ColdFusion中有一个基本的移动登录页面,允许用户输入用户名和密码并登录。成功登录后,页面使用cflocation重定向到主页。但是,当页面成功重定向到主页时,它仍然在位置栏中显示登录页面URL。在整个web应用程序中,我们已经多次使用cflocation,我以前从未遇到过这种行为,也不知道是什么导致了这种行为 页面代码的要点:Jquery mobile 奇怪的cflocation行为:重定向到页面但不更新url,jquery-mobile,redirect,coldfusion,cflocation,Jquery Mobile,Redirect,Coldfusion,Cflocation,我在ColdFusion中有一个基本的移动登录页面,允许用户输入用户名和密码并登录。成功登录后,页面使用cflocation重定向到主页。但是,当页面成功重定向到主页时,它仍然在位置栏中显示登录页面URL。在整个web应用程序中,我们已经多次使用cflocation,我以前从未遇到过这种行为,也不知道是什么导致了这种行为 页面代码的要点: <cfparam name="invalidLogin" default="false"> <cfif cgi.REQUEST_METHOD
<cfparam name="invalidLogin" default="false">
<cfif cgi.REQUEST_METHOD EQ "POST" AND isDefined("form.email") AND isDefined("form.password") and len(trim(form.email)) and len(trim(form.password))>
<!--- call the login method --->
<cfinvoke component="login" method="userlogin" returnvariable="userData">
<cfinvokeargument name="userName" value="#form.email#">
<cfinvokeargument name="password" value="#form.password#">
</cfinvoke>
<cfif userData.isLoggedIn>
<cflocation url="index.cfm" addtoken="no">
</cfif>
<cfset invalidLogin = true />
</cfif>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Log In</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/jquery.mobile.structure-1.3.2.css" rel="stylesheet" type="text/css" />
<link href="css/jquery.mobile-1.3.2.css" rel="stylesheet" type="text/css" />
<link href="css/common.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/jquery.mobile-1.3.2.js"></script>
<script type="text/javascript" src="js/common.js"></script>
</head>
<body>
<div data-role="page" class="bg-color">
<div class="container">
<div data-role="content">
<div class="article">
<div class="logoDiv">
<img src="img/companyLogo.png" />
</div>
</div>
<form action="" method="post" name="frmLogin" id="frmLogin" class="margin-top" data-transition="slide">
<div>
<input type="text" name="email" id="email" placeholder="Username">
<input type="password" name="password" id="password" placeholder="Password">
</div>
<cfif invalidLogin><div>Invalid Login</div></cfif>
<div>
<input type="submit" value="Log In" data-theme="b" />
</div>
</form>
</div>
</div>
</div>
</body>
</html>
登录
无效登录
为了防止jQuery Mobile通过Ajax处理带有重定向的表单,您需要关闭Ajax导航并通过HTTP处理请求
为此,将dataajax=“false”
属性添加到form
标记中。这将仅停止表单上的Ajax导航
注意在关闭Ajax时,将当前表单页面移动到新页面时,将丢失转换,因此data transition=“slide”
将无效
<form action="" data-ajax="false" method="post" name="frmLogin" id="frmLogin">
这会发生在所有设备和移动浏览器上吗?@Antony-到目前为止,我只是在我的计算机的web浏览器上进行测试,我还没有在移动设备上进行测试,可能与jQM Ajax导航有关。尝试将data ajax=false
添加到form
。您是否尝试过使用firebug查看DOM中发生了什么?@Omar-这就解决了问题,谢谢!如果你把它作为一个答案发布(一个关于属性的文档链接也会很有帮助),我会接受