How can I add a JavaScript function before and after the AJAX call?
This my Yii Code:
echo CHtml::ajaxSubmitButton('Create Invoice',$this->createUrl('url'),
array(
'type'=>'POST',
'data'=> 'js:{"merchant_id": $("#merchantSearchForm_merchant_list").val() }',
'success'=>'js:function(string){ $("#merchantProfileForm").html(string); }'
),array('class'=>'someCssClass',));
I need to call a JavaScript function when the user clicks on button, and when the request returns the response, I need to call another JavaScript function.
The workflow would be:
- User clicks on button
- Call
loader();function - AJAX request and return the response
- Call
hidLoder();function