0

我正在使用 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'),当我在上面的代码中注释行时,它工作正常。

4

1 回答 1

2

尝试:

'before'   => '$("img#loader").attr("style", " ")', 
'complete' => '$("img#loader").attr("style", "display:none")',
于 2013-11-20T12:22:09.340 回答