有人对这个问题有答案吗?
基本上,我已经用尽了这里其他问题的所有可能答案,我被迫打开新的求助电话!
问题...我有一个登录页面,其中包含登录表单。提交按钮附加了一个jQuery点击功能。单击函数对某些检查数据库的 php 进行了 ajax 调用。成功后,该位置将被重定向到另一个页面。现在这适用于除最新版本的野生动物园之外的所有浏览器!我也尝试了不同版本的jQuery。这是非常令人沮丧的。请参阅下面的代码以了解您的观点。
任何建议/解决方案将不胜感激。
提前谢谢。
------------更新----------
任何遇到这个问题的人,我想出的解决方案是用AngularJS重写解决方案。我建议你也这样做!
希望这有帮助。
------------.HTML--------------
<form id="loginFRM" style="text-align: center;">
<input style="margin:20px; padding-left:5px;" id="username" name="username" type="text" placeholder="Username...">
<br>
<input style="margin:20px; padding-left:5px;" id="password" name="password" type="password" placeholder="Password...">
<br>
<input style="margin:20px; background-color: white; border: none; padding:10px; padding-left:30px;
padding-right:30px;" id="loginBtn" type="submit" value="Login" onclick="return false;">
</form>
----------jQuery----------
$(document).ready(function(){
$('#loginBtn').click(function(){
var username = $("#username").val(),
password = $("#password").val();
if(username != "" && password != ""){
$.ajax({
type: "GET",
url: './server/index.php',
data: {
username: username,
password: password
},
success: function(response)
{
rowCount = response.ResultSet.RowCount;
if(rowCount > 0){
window.setTimeout(function(){ location.href = "index.html"; },0);
return false;
}
else{
alert('Incorrect details');
}
}
});
}else{
alert('Incorrect details');
}
return false;
});
});
试试看:
------------.HTML--------------
<form id="loginFRM" style="text-align: center;">
<input style="margin:20px; padding-left:5px;" id="username" name="username" type="text" placeholder="Username...">
<br>
<input style="margin:20px; padding-left:5px;" id="password" name="password" type="password" placeholder="Password...">
<br>
<input style="margin:20px; background-color: white; border: none; padding:10px; padding-left:30px;
padding-right:30px;" id="loginBtn" type="submit" value="Login">
</form>
----------jQuery----------
$(window).load(function(){
$('#loginBtn').click(function(event){
event.preventDefault();
var username = $("#username").val(),
password = $("#password").val();
if(username != "" && password != ""){
$.ajax({
type: "GET",
url: './server/index.php',
data: {
username: username,
password: password
},
success: function(response)
{
rowCount = response.ResultSet.RowCount;
if(rowCount > 0){
window.setTimeout(function(){ location.href = "index.html"; },0);
return false;
}
else{
alert('Incorrect details');
}
}
});
}else{
alert('Incorrect details');
}
return false;
});
});
任何遇到这个问题的人,我想出的解决方案是用 AngularJS 重写解决方案。我建议你也这样做!