Nilzone-
Nilzone-

Reputation: 2786

jQuery - blockUI() acts differently depending on browser

I'm trying to implement blockUI-pugin. In Firefox, blockUI works, but unblockUI does not. Firebug keeps telling me unblockUI() is not a function.

Then I tried to change browser (from FireFox to Chrome), just to see if it would make a difference - it did. Now when I run the code, the grey area doesn't appear anymore (this also happens in Safari) + unblockUI is still not working. Firebug shows that all my POST-variables is received and correct.

here is my AJAX-call:

function login() {
    $.ajax({
        url: 'login.php',
        type: 'POST',
        data: $('#login').serializeArray(),
        error: function(data){
            console.log(data);
        },
        success: function(data){
            console.log(data);
            $.unblockUI();
        }
    });
}

And here is my blockUI:

$(document).ready(function() {
    $.blockUI({
        message: $('#message').load('login.html'), 
        css: {backgroundColor: '#00FF'}
    });
});

So, my two question are:

-Why isn't the grey shown in Chrome?

-Why doesn't unblockUI() work?

Thanks a lot!

Upvotes: 1

Views: 1405

Answers (1)

curtisk
curtisk

Reputation: 20175

How are you including/what order are you including the plugin?

Try adding your ajax call in the $(document).ready() so that way you are sure everything is loaded and ready

$(document).ready(function() {
    $.blockUI({
        message: $('#message').load('login.html'), 
        css: {backgroundColor: '#00FF'}
    });

function login() {
    $.ajax({
        url: 'login.php',
        type: 'POST',
        data: $('#login').serializeArray(),
        error: function(data){
            console.log(data);
        },
        success: function(data){
            console.log(data);
            $.unblockUI;
        }
    });
};

});

Upvotes: 0

Related Questions