Mrk Fldig
Mrk Fldig

Reputation: 4486

BlockUI not unblocking

I've been staring at this for HOURS and I can't see why on earth this isn't working, I have confess my JS isn't top notch but to me this looks right?

Basically when I click the blockui comes up fine but it never goes away! Cut down version of the code below...

$(document).ready(function() {
    $("#formdata").toggle();
    $(function() {
        $( "#datepick" ).datepicker();$("#datepick").datepicker({
            dateFormat: "yyyy-mm-dd" });
    });
    $(document).ajaxStart(function() {
        $.blockUI({message: '<h1>Retrieving data</h1>'})
    });
    $(document).ajaxStop(function() {
        $.unblockUI();
    });
});

    $(".button").click(function() {  
    var dataString = $("myform").serialize();

    $.ajax({  
        type: "POST",  
        url: "employerformdata.php",  
        data: dataString,  
        success: function(data) {
            $("submitresult").html(data);
        }
    });
});

Upvotes: 1

Views: 4513

Answers (2)

Zahid Riaz
Zahid Riaz

Reputation: 2889

ajaxComplete function to unblock UI

reference http://docs.jquery.com/Ajax_Events

Upvotes: 1

Matija Grcic
Matija Grcic

Reputation: 13381

I modified a bit your code and tested it in jsfiddle.

   $(document).ready(function() {
        $("#formdata").toggle();
        $(function() {
            $("#datepick").datepicker();
            $("#datepick").datepicker({
                dateFormat: "yyyy-mm-dd"
            });
        });   

     $(document).ajaxStart(function() {
            $.blockUI({ css: { 
                border: 'none', 
                padding: '15px', 
                backgroundColor: '#000', 
                '-webkit-border-radius': '10px', 
                '-moz-border-radius': '10px', 
                opacity: .5, 
                color: '#fff' 
            },message: 'Posting data...'})
        });

    $(document).ajaxStop(function() {
        $.unblockUI();
    });
});
$(".button").click(function() {
    var dataString = $("myform").serialize();

    $.ajax({
        type: "POST",
        url: "employerformdata.php",
        data: dataString,
        success: function(data) {
            $("submitresult").html(data);
        }
    });

});​

Everything is working fine as you can see here http://jsfiddle.net/WmQFt/. I suspect there is a problem with the POST action. Try debugging in developer tools.

Upvotes: 0

Related Questions