jquery mobile破坏了我的POST

use*_*313 3 php post jquery-mobile

我有一个包含HEAD部分和BODY部分的HTML文件(index.html).在BODy部分,我有一个表单,其中一个POST动作指向一个php文件.

如果我添加到HEAD部分jQueryMobile的CDN ...然后POST停止工作.这怎么可能,以及如何避免这种情况?

所以我的头像这样:

<head>
    <title>My Mobile App</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1 maximum-scale=1" />
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css">
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <link rel="apple-touch-icon" href="images/icon57.png" />
    <link rel="apple-touch-icon" sizes="72x72" href="images/icon72.png" />
    <link rel="apple-touch-icon" sizes="114x114" href="images/icon114.png" />
    <link rel="apple-touch-startup-image" href="images/icon320.png" />
    <link rel="apple-touch-startup-image" sizes="768x1004" href="images/icon320.png" />
</head>

** if I comment the jquery.mobile script line the POST works **
Run Code Online (Sandbox Code Playgroud)

POST的BODY看起来像这样:

<body>
    <div data-role="page" id="index">
                <header data-role="header" data-position="fixed">
                    <h1>Mobile APP</h1>
                </header>
                <div data-role="content">
                    <b>Login</b>
                    <form method="POST" action="prologin.php">
                        Name: <input type="text" name="name"><br>
                        Password: <input type="password" name="pass"><br>
                        <input type="submit" value="Login" data-inline="true" data-icon="gear">
                    </form>
                </div>

                <footer data-role="footer" data-position="fixed">
                    <h1>bla bla</h1>
                </footer>
    </div>
</body>
Run Code Online (Sandbox Code Playgroud)

现在我的PHP文件prologin.php更复杂,但出于调试目的,我把它减少到:

<?php
echo 'name='.$_POST['name'].' and pass='.$_POST['pass'];
?>
Run Code Online (Sandbox Code Playgroud)

因此,当我使用jQuery.mobile脚本时,单击Login按钮的结果是一个未定义的页面,如果我查看页面源...它是空的,我的意思是它看起来像:

name= and pass=
Run Code Online (Sandbox Code Playgroud)

什么都没有张贴如果我用jQuery.mobile注释脚本行,结果显示它应该是什么,我的意思是:

name=myusername and pass=mypassword
Run Code Online (Sandbox Code Playgroud)

(当然myusername和mypassword是我在输入框中输入的值)我做错了什么?

这些相同的页面和代码在另一台服务器上工作正常.但现在它不再起作用了.可能有什么不对?原始主机也是CENTOS系统,大部分都是相同的配置.在工作服务器上我有PHP版本5.3.3并且在这个(不工作)我有PHP版本5.1.6如何使用jquery mobile影响HTML POST以便它将停止工作?

我的意思是,我该如何解决?

我会尝试更新我的PHP,但在这台服务器上有其他依赖这个版本的应用程序,我会避免更新.

Gaj*_*res 5

只需将此属性添加到您的表单:

data-ajax="false"
Run Code Online (Sandbox Code Playgroud)

它将阻止jQuery Mobile劫持表单提交逻辑.

您的表单应如下所示:

<form method="POST" action="prologin.php" data-ajax="false">
Run Code Online (Sandbox Code Playgroud)