ajax 调用后重新渲染/刷新同一视图
我只是想问是否可以通过dojo xhrpost重新渲染相同的视图?
在我的 /app/index.phtml 页面上,我有一个按钮,它将通过 dojo xhrpost 触发一个操作,该操作将调用相同的 /app 操作控制器。
它成功调用控制器,但页面未使用更新的数据进行渲染。
这是ajax调用部分
var xhrArgs = {
url: "/app",
handleAs: "text",
load: function(data) {
console.log(data);
},
error: function(error) {
console.log(error);
}
}
dojo.xhrPost(xhrArgs);
控制器
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();
}
我得到了firebug的响应,它给了我渲染的页面,但实际视图本身没有重新加载新的应用程序数据($this->view->apps)
我错过了吗某物?请帮忙。
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 rendering 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用 Dojo 将新检索到的数据呈现到页面的 DOM 中。控制器会将其返回到变量中,但不会显示它。
希望有帮助,
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,