<div onclick="send_ajax_request(); document.getElementById('loading').style.display = 'block';">
<div style="display: none" id="loading">Loading ...</div>
</div>
send_ajax_request () is your function to call an ajax request. the second statement will make the inner div visible (style = "display: none" will make it invisible by default).
source
share