微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php – jquery mobile破坏了我的POST

我有一个包含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 **

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>

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

<?PHP
echo 'name='.$_POST['name'].' and pass='.$_POST['pass'];
?>

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

name= and pass=

,所以什么都没发布
如果我用jQuery.mobile注释脚本行,结果会显示它应该是什么,我的意思是:

name=myusername and pass=mypassword

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

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

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

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

解决方法:

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

data-ajax="false"

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

您的表单应如下所示:

<form method="POST" action="prologin.PHP" data-ajax="false">

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐