POST Method not working with jquery.mobile-1.4.0.min.js

南笙酒味 提交于 2020-01-06 11:48:54

问题


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.

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>

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

<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>";


?>

回答1:


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 ..

In jQuery Mobile, form submissions are automatically handled using Ajax whenever possible

To submit the form normally you can use data-ajax="false" in form

<form data-ajax="false" action="" method="">


来源:https://stackoverflow.com/questions/23424403/post-method-not-working-with-jquery-mobile-1-4-0-min-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!