I have written a html code for login as follwing
<div id="wrapper">
<div id="page">
<div class="aLogin">
<label>User Name : </label>
<input type="text" class="lname" />
<label>Password : </label>
<input type="password" class="lpwd" />
<input type="submit" class="logSubmit" value="LOGIN" />
<p class="lalert">test alert</p>
</div>
</div>
and written jQuery for validation.It replace the alert(here i used <p class="lalert">test alert</p>
) dynamically.
The problem is, when i run this in IE, the alert message was displayed twice. But in other browsers no problem.
jQuery
$(document).ready(function(){
$('.logSubmit').click(function(){
var name = $('.lname').val();
var pwd = $('.lpwd').val();
$.post("/login.php",{name:name,pwd:pwd}).success(function(data){
var obj = jQuery.parseJSON(data);
$('.lalert').fadeIn('slow');
if(obj.success == 1){
$('.lalert').css('color','#067800');
$('.lname').val('');
$('.pwd').val('');
$('.lalert').html(obj.msg);
}else{
$('.lalert').css('color','#CC0000');
$('.lalert').html(obj.msg);
}
});
});
});
login.php
<?php
$name = $_POST['name'];
$pwd = $_POST['pwd'];
$err['success'] = 0;
$err['msg'] = '';
if($name != 'admin'){
$err['msg'] = 'Invalid Name';
}else if($pwd != 'admin'){
$err['msg'] = 'Invalid Password';
}else{
$err['success'] = 1;
$err['msg'] = 'Success';
}
echo json_encode($err);
?>
I can't found why this happening. Can anybody help me..?
In browsers like Internet Explorer, press Ctrl+U to access the HTML source code of a website.
Yes it does. Perhaps a better question is what modern web features IE8 supports.
Internet Explorer 11 supports HTML5 and there shouldn't be any problem in YouTube.
Hi You have forgot to write the "return false".
$('.logSubmit').click(function(){
var name = $('.lname').val();
var pwd = $('.lpwd').val();
$.post("/login.php",{name:name,pwd:pwd}).success(function(data){
var obj = jQuery.parseJSON(data);
$('.lalert').fadeIn('slow');
if(obj.success == 1){
$('.lalert').css('color','#067800');
$('.lname').val('');
$('.pwd').val('');
$('.lalert').html(obj.msg);
}else{
$('.lalert').css('color','#CC0000');
$('.lalert').html(obj.msg);
}
});
return false;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With