Post runs asynchronously, so the code does not wait for it to finish to
execute the $.unblockUI(priceElement);.  The set timeout won't be too
helpful because you dont know how long the request will take until it has
already happened.

What you likely want to do is to use $.ajax rather than $.post.  That will
let you have an event when your ajax call finishes(success, error), and turn
off blockui at that point

something like this

$('#priceupdate').click(function() { 
        $.blockUI(priceElement, { width: '300px' });
        $.ajax({
                url :someurl.php,
                data: 'data=somedata',
                success: function(response){ alert('success');
$.unblockUI(); },
                error: function(){ alert('oh crap'); $.unblockUI(); }
          })

});



enchen wrote:
> 
> Hi is it possible to have the overlay stay visible all through the process
> while doing a $.post request?
> 
> Mine disappears almost immediately...
> 
> Code looks like: 
> 
> <script type="text/javascript"><!--
> jQuery.noConflict();
> $(document).ready(function() {
>  
>       var priceElement = $('#domCheckPrices'); 
>       $('#priceupdate').click(function() { 
>               $.blockUI(priceElement, { width: '300px' });
>               $.post("#spRequest");
>               //setTimeout('5000'); ?? or similar
>               $.unblockUI(priceElement);
>       });
> });
> 
> // -->
> </script>
> 
> 
> I've tried with various implementations of setTimeout and a jQuery pause
> function I found, but it seams I'm not getting where I want whatever I
> try...
> 
> Basically all I need is a overlay that blocks user input when the submit
> button is pressed, which also displays some useful information about
> what's being done. E.g. the prices are being updated or the form is
> submitted... The overlay would then disappear when the page is completely
> reloaded.
> 
> Any help would be greatly appreciated.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Tweaking-the-BlockUI-Plugin-tf4341787s15494.html#a12368633
Sent from the JQuery mailing list archive at Nabble.com.

Reply via email to