Reputation: 595
I am using cakephp Jshelper for ajax calls.I want to show loader before ajax call but when I add before event option ,ajax call stops working. I am using following code
$data = $this->Js->get('#PostWebadminAdd1Form')->serializeForm(array('isForm' => true, 'inline' => true));
$this->Js->get('#PostWebadminAdd1Form')->event(
'submit', $this->Js->request(
array('action' => 'ajax_add_post', 'controller' => 'posts'), array(
'update' => '#successBox',
'data' => $data,
'async' => true,
'dataExpression' => true,
'method' => 'POST',
'before' => $this->Js->get('#loader')->effect('show'),
//'complete' => $this->Js->get('#loader')->effect('hide'),
)
)
);
echo $this->Js->writeBuffer();
Dont know what is the problem here. when i comment line 'before' => $this->Js->get('#loader')->effect('show'),
in above code it works fine .
Upvotes: 0
Views: 422
Reputation: 777
try:
'before' => '$("img#loader").attr("style", " ")',
'complete' => '$("img#loader").attr("style", "display:none")',
Upvotes: 2