dileepindla
dileepindla

Reputation: 1

Jquery ajax not working in firefox

My code is working in chrome,safari but its not working in firefox.

Here is my code

<script>
$(document).ready(function () {

    $("#loginform").on('submit',(function(e) {

        e.preventDefault();

        $('#loading').html("Loading....");

        $.ajax({
            url: "login.php",
            type: "POST",         
            data: new FormData(this), 
            contentType:false,     
            cache: false,            
            processData:false, 
            async:false,                    
            success: function(data)  
            {
                $('#loading').hide();
                $("#message").html(data);
            }
        });

        return false;

    }));

});
</script>

Can anyone solve this issue??? I have one more same script in the same page only url is different but its working fine,but this script is not working .Iam getting empty data .But in chrome,safari its working fine.

My Html Code :

<form role="form" method="post" id="loginform" action="">
            <div class="form-group">
              <label for="username">Username</label>
              <input type="text" class="form-control" id="username" name="username" placeholder="Enter Username" required>
            </div>
            <div class="form-group">
              <label for="password"> Password</label>
              <input type="password" class="form-control" id="password" name="password" placeholder="Enter password">
            </div>
            <div class="checkbox">
              <label><input type="checkbox" value="" name="user_rememberme" checked>Remember me</label>
            </div>
              <div id="loading"></div>
              <div id="message"></div>
              <button type="submit" name="login" class="btn btn-success pull-right">Login</button>
          </form>

Upvotes: 0

Views: 2989

Answers (2)

madalinivascu
madalinivascu

Reputation: 32354

Try this:

<script>
$(document).ready(function () {

    $("#loginform").on('submit',(function(e) {
        dta = $(this).serialize();
        e.preventDefault();

        $('#loading').html("Loading....");

        $.ajax({
            url: "login.php",
            type: "POST",         
            data:dta,                                
            success: function(data)  
            {
                $('#loading').hide();
                $("#message").html(data);
            }
        });

        return false;

    }));

});
</script>

Upvotes: 0

coolguy
coolguy

Reputation: 7954

Never use async:false in ajax call unless you knows specifically wat you are doing.The problem is that async:false freezes the browser until ajax call is complete (either error or success).set it to true or remove it (by default it is true).Implement error block too and check if its an error from server side

success: function(data)  
{
$('#loading').hide();    
$("#message").html(data);
},error:function(data){
  console.log(data)
}

Upvotes: 3

Related Questions