AjaxSubmitButton : waiting effect

What I’m trying to do :

When I click to the ajaxSubmitButton, it will do an insert to database and I want I generate the text : “Importing” when It’s done : “Done”

What I’ve tried :




<?php

    echo CHtml::ajaxSubmitButton("Import",

            CController::createUrl('stock/UpdateAjax', array('dir' => $dir)),

            array(

                'update' => '#status'),

            array('id' => 'ajaxButton'));


?>



I put this in a form and I have <div id=status></div> below :)

How about using ‘beforeSend’ and ‘complete’ options? Perhaps something like (not tested):




'beforeSend'=>"function(){

   $('#status').html('Import');

}",

'complete'=>"function(){			

   $('#status').html('Done');

}"		



I think we should write ‘js:function() [the rest]’ instead of ‘function() [the rest]’ . I try this now and report later :)