POST方法不适用于jquery.mobile-1.4.0.min.js [英] POST Method not working with jquery.mobile-1.4.0.min.js
问题描述
我正在开发phonegapp应用.在 action.php 文件中有一个简单的登录表单,出于测试目的,我只是在其他文件 see.php 中打印Submit变量.
I am developing a phonegapp app. Have a simple login form in action.php file and for test purpose I am just printing the submit variable in other file see.php.
问题是,如果我在 action.php 中包含以下代码行,则不会打印来自表单的提交变量:
Issue is that if I include following line of code in action.php then submitted variables from form are not getting printed:
<script src="http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js" type="text/javascript"></script>
但是,如果我从 action.php 中删除上述行,则表单将正确提交,并且输入变量将被打印在 see.php
But If I remove the above line from action.php, form is getting submitted properly and input variables are getting printed in see.php
action.php
action.php
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Application</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.0/jquery.mobile.structure-1.4.0.min.css" />
<link href='http://fonts.googleapis.com/css?family=EB+Garamond&subset=latin,cyrillic-ext,vietnamese,latin-ext,cyrillic' rel='stylesheet' type='text/css'>
<script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js" type="text/javascript"></script>
</head>
<body>
<form action="see.php" method = "post">
<label for="Cedula" style="font-size:10px; color:#FFF; text-shadow:none">Cedula</label>
<input type="text" name="usr" id="usr" value="username" data-clear-btn="true">
<label for="Contrasena" style="font-size:10px; color:#FFF; text-shadow:none">Contrasena</label>
<input type="password" name="pwd" id="pwd" value="password" data-clear-btn="true">
<input type="submit" data-role="button" style="font-weight:100" value="Submit"/>
</form>
</body>
</html>
see.php
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$uid = $_POST['usr'];
$upwd = $_POST['pwd'];
echo $uid;
echo "<br>";
echo $upwd;
echo "<br>";
?>
推荐答案
正如您在控制台(网络)中所看到的,将调用see.php并打印post的值.您可以打开萤火虫并检查结果..
As you see in console ( network ) , see.php is being called and values of post are printed . You can turn your firebug ON and check the results ..
在jQuery Mobile中,尽可能使用Ajax自动处理表单提交
In jQuery Mobile, form submissions are automatically handled using Ajax whenever possible
要正常提交表单,您可以在表单中使用data-ajax ="false"
To submit the form normally you can use data-ajax="false" in form
<form data-ajax="false" action="" method="">
这篇关于POST方法不适用于jquery.mobile-1.4.0.min.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!