开发者

Re-render/refresh same view after ajax call

开发者 https://www.devze.com 2023-04-12 06:21 出处:网络
I just want to ask if it is possible to re-render the same view through dojo xhrpost? On my /app/index.phtml page I have a button that will fire an action through dojo xhrpost which will call the sam

I just want to ask if it is possible to re-render the same view through dojo xhrpost?

On my /app/index.phtml page I have a button that will fire an action through dojo xhrpost which will call the same /app action controller.

It successfully calls the controller but the page is not renderi开发者_运维百科ng with the updated data.

Here's the ajax call part

  var xhrArgs = {
            url: "/app",
            handleAs: "text",
            load: function(data) {
                console.log(data);
            },
            error: function(error) {
                console.log(error);
            }
    }
    dojo.xhrPost(xhrArgs);

Controller

      public function indexAction()
{
    $apps = new Application_Model_Application();
    if($this->_request->isPost()){
          $this->view->apps = $apps->getAppsById("2");
    }else{
          $this->view->apps = $apps->getAllApps();
    }
    $this->render();
 }

I'm getting the response on firebug which gives me the rendered page but the actual view itself is not re-loaded with the new apps data ($this->view->apps)

Am I missing something? Please help.


You'll need to use Dojo to render the new retrieved data into the DOM of your page. The controller will return it into the variable, but won't display it.

Hope that helps,

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号