我有一个Ajax登录表单,但它只适用于Firefox。在其他浏览器上,它不断发布表单并加载功能页面。我希望它将2个字段发布到功能页面并检查后台进程并将其写入loginform.html中的#resultgiris标记。
loginform.html
<form id="girisformu" action="fonksiyon/loginkontrol.php" onsubmit="return false;" data-parsley-validate class="form-horizontal form-label-left" >
<div class="form-group">
<div class="col-md-12 col-sm-12 col-xs-12">
<input type="text" id="user_id" name="user_id" class="form-control has-feedback-left" data-inputmask="'mask' : '99999999999'" placeholder="Kullanıcı ID">
<span class="fa fa-user form-control-feedback left" aria-hidden="true"></span>
</div>
</div>
<div class="form-group">
<div class="col-md-12 col-sm-12 col-xs-12">
<input type="password" name="password_giris" id="password_giris" class="form-control has-feedback-left" placeholder="Şifre">
<span class="fa fa-key form-control-feedback left" aria-hidden="true"></span>
</div>
</div>
<div class="form-group">
<div class="col-md-12 col-sm-12 col-xs-12 pull-right">
<center><h5><a href="#kayitOl" data-toggle="modal" data-target="#kayitOl"><span class="fa fa-user-plus" aria-hidden="true"></span> Kayıt Ol</a> - <a href="#sifremiUnuttum" data-toggle="modal" data-target="#sifremiUnuttum"><span class="fa fa-question-circle" aria-hidden="true"></span> Şifremi Unuttum</a></h5></center>
</div><div class="col-md-12 col-sm-12 col-xs-12 pull-right">
<center><button type="reset" class="btn btn-primary"><span class="fa fa-trash" aria-hidden="true"></span> Temizle</button>
<button id="girisbtn" class="btn btn-success"><span class="fa fa-sign-in" aria-hidden="true"></span> Giriş Yap</button></center>
</div>
</div>
</form>
loginkontrol.php(功能页面)
<?php
include_once('../inc/database.php');
$userid = $_POST['user_id'];
$password = $_POST['password_giris'];
$result = mysqli_query($baglan, "SELECT `userid`,`sifre`
FROM `uye` WHERE `userid` = '$userid' AND `sifre` = '$password'") or die (mysqli_error($baglan));
$row = mysqli_fetch_assoc($result);
if(mysqli_num_rows($result) <= 0){
echo "Login failed";
else{
echo "Successful login";
}
?>
login.js
$("#girisbtn").click( function() {
document.getElementById("loadinggiris").style.display = 'inline';
$.post( $("#girisformu").attr("action"),
$("#girisformu :input").serializeArray(),
function(info){ $("#resultgiris").html(info);
});
});
$("#girisformu").submit( function() {
event.preventDefault();
});
function clearInput() {
$("#girisformu :input").each( function() {
$(this).val('');
});
}
答案 0 :(得分:0)
感谢@Cbroe的评论,我解决了我的问题。 我定义了一个函数;
<script>
function engelle(e){
e.preventDefault();
}
</script>
然后将登录按钮的onclick更改为'onclick =“engelle(event)”'