首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Yii和ajax在提交后更新不会呈现更新表单页面

Yii和ajax在提交后更新不会呈现更新表单页面
EN

Stack Overflow用户
提问于 2014-04-08 02:17:08
回答 1查看 303关注 0票数 0

我使用的是Yii Mvc框架,使用的是ajax和PHP。在创建/保存评论后请求更新时,我无法使其工作。我需要在创建/保存后刷新页面,才能使更新/保存生效。我遗漏了什么?如何使click事件不返回到最后调用的控制器/action?提前感谢您的帮助。

具体步骤如下

代码语言:javascript
复制
                                                            **adresses called**
1. the user request the index page   (normal call)          /post/index
   (the page index is rendered)
2. the user click to create comment   (ajax call)     /post/createComment
   (the comment-form is rendered inside the index page)
3. the user click to save the comment (ajax call)           /post/saveComment  
   (the comment is saved and the comment-form is removed)
4. the user clcik to update the comment (ajax call)         /post/saveComment 
                                                            is called again
                                                            nothing happens

if before point 4 I refresh the page

4. the user click to update the comment (ajax call)         /post/updateComment
   (the comment-form with existing comment is rendered)

5. the user click to save the commnt (ajax call)            /post/saveComment
   (the comment is saved and the comment-form is removed)   --> ok
EN

回答 1

Stack Overflow用户

发布于 2014-04-08 03:30:30

通过ajax更新页面在Yii中不能自动工作。您可以使用CActiveFrom小部件及其ajax验证功能,或者使用javascript手动更新一些页面元素。如果您使用的是CAtiveForm,我们需要查看视图和控制器源代码来帮助您。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22920060

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档