I would have a similar problem when I wanted to perform some actions with ajax that didnβt take so much time, but enough to make the user think βwhat is happening? Am I doing what I want?β.
I found a jQuery plugin called blockUI (really cool!) That display a message while processing your stuff.
And this is how I use it. First, the function that processes the request:
function proceedToSend( requesterName, requesterId ) { //Here the wait/processing message is displayed $().ajaxStart($.blockUI({ message:$('#waitMessage')})); $.ajax({ type :"POST" , url : http://example.com/myurl.php dataType: yourDataType , data : myData , success :function ( response ) { //response processing if needed // Here the wait/processing messages is hidden $().ajaxStop($.unblockUI({ message:null })); } , error :function () { alert('there was an error processing the request!!'); $().ajaxStop($.unblockUI({ message:null })); } }); }
And finally, you need to add this to your page so that the message displays:
<div id="waitMessage" class="dataContainer" style="display: none;"> <p style="font-size: 30px;">Processing request...</p> </div>
This hopefully helps!;)
Manei source share