Click here to Skip to main content
15,890,186 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi guys,

I'm working on a loading screen using JS BlockUI but I think my code is kinda wrong..
I'm trying show loading screen on my button click and when request ends the loading screen must unload...

Here is my JS code...

HTML
<script type="text/javascript" src="js/BlockUI-2.42.js"></script>

<script type="text/javascript" language="javascript">

$(document).ready(function() {

var messageOr = "Loading... Please Wait";

//Block Screen

$(".button").click(function() {
$.blockUI({
message: messageOr ,
overlayCSS: { backgroundColor: ‘#000′,
css: {
border: ’1px solid #CCC’

}
}
});
});

//Unblock Screen

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(
function() {
$.unblockUI();

});
});

</script>


I got that code searching on google and I'm pretty new at Jquery, please any solution?
Posted

 
Share this answer
 
v2
Comments
Sir.Big 26-Jun-12 6:57am    
thanks but I'm looking for an example using BlockUI... I think my code above works with a little fix.

Or if you can please show me an example using BlockUI and Page Request. Thank you anyways
As far as I can diagnose the problem, you havent included the JQuery file... Please download it or use a CDN to get the JQuery file.

The head section should contain the following script tags.

HTML
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.5.1.min.js" type="text/javascript"></script>

<script type="text/javascript" src="js/BlockUI-2.42.js"></script>


If does not solve your problem, do let me know. I will update this solution and help you. Thanks.
 
Share this answer
 
Comments
Sir.Big 27-Jun-12 5:02am    
lol. Is not cause of that script tag...
Pankaj Nikam 27-Jun-12 8:07am    
If your problem is not solved, please update the code to include the full code. That way I can understand it in a better way. Thanks.
You can do this without using any plugin



<!-- make it last -->
<div id="blocker">
<div>Loading...</div>
</div>


CSS
#blocker
{
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: .5;
    background-color: #000;
    z-index: 1000;
}
    #blocker div
    {
        position: absolute;
        top: 50%;
        left: 50%;
        width: 5em;
        height: 2em;
        margin: -1em 0 0 -2.5em;
        color: #fff;
        font-weight: bold;
    }

And Javascript that clears blocking:

$(function(){
    $("#blocker").hide();
});
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900