我正在使用cakephp Jshelper进行ajax调用。我想在ajax调用之前显示加载器但是当我在事件选项之前添加时,ajax调用停止工作。我正在使用以下代码
$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();
不知道这里有什么问题。当我在上面的代码中对行'before' => $this->Js->get('#loader')->effect('show'),
进行评论时,它可以正常工作。
答案 0 :(得分:2)
尝试:
'before' => '$("img#loader").attr("style", " ")',
'complete' => '$("img#loader").attr("style", "display:none")',