Dav*_*tze 9 redirect http-status-code-301 jquery-mobile
我正在使用jQuery 1.6.1与jQuery Mobile 1.0.1.当您链接到然后尝试执行301重定向的页面时,我会遇到问题.
我在以下网址设置了示例页面:http://www.widgetsandburritos.com/jquery-mobile-test/
这个页面上唯一的东西是jQuery Mobile包含和另一个页面的链接,该页面在其他地方有301重定向.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
</head>
<body>
<a href="301test.php">301 test</a>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
301test.php具有以下内容:
<?php
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: 301success.html" );
?>
Run Code Online (Sandbox Code Playgroud)
这应该只是简单地将浏览器传递给301success.html.如果您直接转到该URL,它会起作用
http://www.widgetsandburritos.com/jquery-mobile-test/301test.php
但是当你使用jQuery Mobile点击页面上的链接时,它会显示"undefined".jQuery Mobile目前无法处理重定向吗?
任何可能的工作?
谢谢你的帮助.
编辑[3/23/12 12:41 AM CST]
我还在jQuery Mobile论坛上发布了这个问题.有人建议在锚标记中添加rel ="external".如果你所做的只是建立一个链接,这在技术上是有效的,但是如果你通过其他机制(例如POST请求)进行重定向,则无法解决问题.
为了说明,我在http://www.widgetsandburritos.com/jquery-mobile-test/test2.html设置了一个二级测试.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
</head>
<body>
<form method="post" action="301test.php">
<input type="submit" value="test" />
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
它不是从链接到达301test.php重定向页面,而是现在我们提交的表单的位置.这将使用的上下文,如果您提交一个有错误的表单,它将保持在同一页面,允许您纠正错误.如果没有错误,它会将您重定向到成功页面.这样做是为了避免在用户刷新浏览器时再次提交表单.它在普通的Web应用程序中运行良好.但是在与jQuery Mobile的组合中它似乎不起作用.
只是想我会给这个问题的其他人提供一些额外的背景信息.
Dav*_*tze 20
弄清楚我自己的问题的答案.在上面,我提到使用<form>标签导致问题.浏览完jQuery Mobile文档后,我找到了这个页面:http://jquerymobile.com/test/docs/forms/forms-sample.html
这里的诀窍是如果你正在做一个表单,强迫它不使用AJAX.你这样做是通过添加
data-ajax ="false"到FORM标签.
所以这种变化
<form method="post" action="301test.php">
Run Code Online (Sandbox Code Playgroud)
至
<form method="post" action="301test.php" data-ajax="false">
Run Code Online (Sandbox Code Playgroud)
只是重申上面所说的话.如果您需要使用锚链接执行某些操作,只需将rel ="external"添加到其中即可.
所以这种变化
<a href="301test.php">301 test</a>
Run Code Online (Sandbox Code Playgroud)
至
<a href="301test.php" rel="external">301 test</a>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7142 次 |
| 最近记录: |