Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8615909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:29:39+00:00 2026-06-12T05:29:39+00:00

I want to block the current page when a specific ajax call is made

  • 0

I want to block the current page when a specific ajax call is made and use a blockUI as a message box. I can’t just use $(document).ajaxStart($.blockUI).ajaxStop($.unblockUI);

My code is the following..

bc.find('.submit').click(function (e) {
    e.preventDefault();
    if ($(this).hasClass('lock'))
        return;
    $.blockUI();
    $(this).addClass('lock');
    bc.submit();
});

var validator;
validator = bc.validate({
    ignore: '',
    rules: {
        UserName: {
            required: true
        }
    },
    messages: {
        UserName: 'must have',
    },
    submitHandler: function (form) {
        $.ajax({
            url: '/yyyy/xxxx',
            type: 'POST',
            data: postdata,
            complete: function () {
                bc.find('.submit').removeClass('lock');
            },
            success: function (data) {
                if (data.status == 'OK') {
                    $.blockUI({ message: 'OK' });
                    ......
                }
                else {
                    switch (data.status) {
                        case 'xxx':
                        ......
                    }
                    $.unblockUI();
                }
            },
            error: function () {
                $.unblockUI();
                alert('xxx');
            }
        });
    }
});

The scenario is that when I click the .submit button, the page is blocked and a ajax call is made to the server to get a data response. When the ajax call is successful, I unblock the current page and if data.status is ‘OK’, I show a message box (also based on blockUI plugin). Else I show an error on the current page, and then unblock it.

Edit at 2016, there is a edit which change the question meaning(maybe due to my very poor English at that moment), I have rolled change back here, and make it more clear, please do not change below again.

But in fact, only after ajax call is completed (debug step over the code in ajax complete handler), then see:

  1. first $.blockUI(); excuted
  2. execute $.blockUI({ message: 'OK' }) or not
  3. then $.unblockUI() be called

(Above is what I mean abnormal execution sequence of chrome or firefox debug tool in the answer.because blockui code should not be executed after ajax complete)

It’s not what I want, and I can’t figure this out.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:29:40+00:00Added an answer on June 12, 2026 at 5:29 am

    The problem was an execution sequence anomaly caused by browser’s debug tools in both chrome and firefox. With the debugger, I confirmed whether $.blockUI() executed before the ajax call or not. It was always executing after I stepped over the complete handler in ajax. Just now, I set a breakpoint in server side code and I found that execution sequence becomes normal as I want it be!

    update at 2016-01-25:

    Note:

    1. This answer is answered at 2012-09-26. I don’t know whether chrome or firefox still has something abnormal execution sequence when doing a async call now.(But I remember, at that time, set a break point on the line – $.blockUI({ message: 'OK' }); in chrome debug tool, type F10(go next) , would see chrome just step over the break point, and nothing heppen)
    2. Actually there is no error in the question’s code. I think why I ask this question is only because I see the abnormal execution sequence in debug tool, which make me confuse, and the answer is here. If you want to find out why your code not work or something else , you’d better to find other answers or ask a new question.
    3. About abnormal execution sequence, now, I think maybe it is by blockui too. Because we don’t see how $.blockUI() worked, maybe block element function is stored deep inside the chrome execution callback stack. I may place the breakpoint at wrong line If that assumption is true(so maybe need set breakpoint in blockui source code)

    And, I haven’t work with blockui for many years.If you just want a block message box, I suggest sweetalert.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to block a specific phone number that is in my database I
I want to block special character in this code. In other words, user can
I want to block few mobile numbers from my application. I mean can receive
I want to block scrolling page out of the iPhone screen (when gray Safari's
I want to use jQuery to animate a simple vertical menu that can be
I made following jsf page. In my Managed Bean i want evaluate the input,
Suppose this is what we want in every page, we'd create base_template.html <title>{% block
I want to block an entire ip range from my webserver but I'm not
I want to block non-browser clients from accessing certain pages / successfully making a
I want to block all incoming connections with iptables on my android device. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.