CSS – Dimming Screen, waiting for Ajax Call

To dim the screen while waiting for an Ajax call to finish:

CSS

#loading-ajax {
    background: rgba(0,0,0,.2) url('/images/ajax-loader.gif') no-repeat 50% 50%;
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 999;
}

html

<div id="loading-ajax" style="display:none"></div>
(...)
<a href="javascript:;" onclick="start_ajax();"><img src="/images/my_img.gif" /></a>

javascript

function start_ajax()
{       jQuery("#loading-ajax").show();
        jQuery.get( "my_ajax_url", {
                action: "do_something"
                } )
        .done(function( data ) {
                jQuery("#loading-ajax").hide();
                if(data == 'error') alert('error detected')
                else alert(data);
        });
}

Resource:
http://stackoverflow.com/questions/7046484/dim-the-page-and-show-a-loading-indicator