<!-- jQuery / jQueryMobile Scripts -->
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
<script>
// Attach a submit handler to the form
$("#loginForm").submit(function (event) {
// Stop form from submitting normally
event.preventDefault();
// Get some values from elements on the page:
var $form = $(this),
username = $form.find("input[name='username']").val(),
password = $form.find("input[name='password']").val(),
url = $form.attr("action");
// Send the data using post
var posting = $.post(url, { username: username, password: password });
// Put the results in a div
posting.done(function (data) {
var content = $(data).find("#content");
$("#result").empty().append(content);
});
});
</script>
<div data-role="page" data-theme='b' id="1">
<div data-role="header" data-position="fixed" data-tap-toggle="false" data-theme='b'>
<a href="index.html" data-ajax="false"><i class='fa fa-bars'></i></a>
<h1>Glue Plus+</h1>
</div>
<div data-role="content">
<div class="inset">
<h1>Login</h1>
</div>
<form method="post" action="http://url/Sugar/php_Calls/login.php" id="loginForm" data-ajax="false">
<div data-role="fieldcontain">
<label for="name2b">Email:</label>
<input type="email" name="username" id="emailaddress" value="" data-clear-btn="true" placeholder="Type your email here...">
</div>
<div data-role="fieldcontain">
<label for="name2b">Password:</label>
<input type="password" name="password" id="password" value="" data-clear-btn="true" placeholder="Type your password here...">
</div>
<div data-role="fieldcontain">
<input type="checkbox" name="checkbox-1a" id="checkbox-1ab" checked="">
<label for="checkbox-1ab">Keep me logged in</label>
</div>
</form>
<button type="submit" id="btnlogin" name="login" href="#mainpage" data-inline="true">Submit</button>
</div>
</div>
当我通过firebug进行调试时,它不会进入表单提交
答案 0 :(得分:0)
您的按钮位于表单范围之外。您可以在form="loginForm"
:
<button type="submit" form="loginForm" id="btnlogin" name="login" href="#mainpage" data-inline="true">Submit</button>
There are many questions like yours。下次在发布之前进行搜索。
答案 1 :(得分:-1)
您需要在表单中放置按钮或添加表单属性
<button type="submit" id="btnlogin" ... form="loginForm">Submit</button>
正如@Anthoy Grist指出的那样,您需要在标记之后放置脚本或使用就绪事件。
$(function() {
$("#loginForm").submit(function (event) {
...
});