Function call before synchronous call

I have a simple question (but the answer does not seem simple).

I have an AJAX synchronous call in my code, and I want to call a function before this synchronous call.

The function I want to call is simply

$.blockUI();

from jQuery BlockUI Plugin.

I just tried putting this line before calling $ .ajax, but blockUI seems to be called after a synchronous call.

Then I tried to use the beforeSend option in $ .ajax, the same problem as above.

Thank you in advance for any answer you could bring (except for using an asynchronous call, which is simply not possible in my case ...)

The code is available here: http://jsfiddle.net/vWsus/2/

+5
source share
4

, , , . , , DOM . DOM, Ajax.

$.blockUI({ message: '<p>foo</p>' });
window.setTimeout( ajxCallFnc, 100);
+4

, blockUI , , ( " ", DOM). , , blockUI ajax, beforeSend, .

jQuery , , jQuery ( , xhr , ).

, , . .

XMLHttpRequest

+1

$. blockUI onBlock. - :

$.blockUI({ 
    message: '<img id="processing" src="images/loading.gif" />', 
    onBlock: function() {
        // make your sync call here
        $.ajax({
            type: 'POST',
            cache: false,
            async: false,               
            url: blahblah,
            dataType: 'json'                
        }).done(function(data){
            //process response

        });
    }
}); 
0
this.notifyFixed=function(type,msg,callback){
        this.showNotification(type, msg);
            window.setTimeout(function(){
                if(typeof callback ==="function"){
                    callback();
                }
            },100);
    };

notifyFixed, , ajax, , , epascarello, , , .

, ,

0

All Articles