Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML issues in IE

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

like image 330
Vinu Avatar asked Jun 29 '12 06:06

Vinu


People also ask

How do I get HTML to work on Internet Explorer?

In browsers like Internet Explorer, press Ctrl+U to access the HTML source code of a website.

Does HTML support Internet Explorer?

Yes it does. Perhaps a better question is what modern web features IE8 supports.

Does IE work with HTML5?

Internet Explorer 11 supports HTML5 and there shouldn't be any problem in YouTube.


1 Answers

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;
  }); 
like image 167
Hemant Kumar Avatar answered Sep 28 '22 15:09

Hemant Kumar