学习Yii:用ajax检查行不通
我有一个小问题,但它似乎大到足以阻碍我的工作。 正如我在标题中所说,我正在学习 Yii,在开发我的项目后,我意识到我没有 ajax 检查。
我尝试通过将 enableAjaxValidation 设置为 true 来解决此问题,但没有成功。我尝试使用 PerformAjaxValidation 方法,但同样没有成功。第三种方法是复制performAjaxValidation的内容并将其粘贴到我的方法中(就像在文档中一样,与Yii生成的代码相同。
我检查了我的js并且它们已加载。
这可能是什么?我该如何解决这个问题?问题是我需要在用户填写表单时修改我的字段,
谢谢!
PS:我从 stackoverflow 检查了一些主题,但唯一相关的是 Yii - 带验证的 Ajax 表单
I have a small problem that seems to be big enough to hold me from my work.
As I said in the title, I am leaning Yii and after I developped my project, I realized that I don't have ajax check.
I tried to solve this by setting enableAjaxValidation to true and it didn't worked. I tried to make use of the method performAjaxValidation and, again, it didn't worked. The third way was to copy the content of performAjaxValidation and paste it inside my method (like in documentation and identical with the code generated by Yii.
I checked my js and they are loaded.
What could it be? How can I solve this? The problem is that I need my fields to modify while the user is completing the form.
Thank you!
PS: I checked some topics from stackoverflow but the only one who was related was Yii - Ajax Form with validations
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保正在验证的 from 与
performAjaxValidation
函数中使用的 ID 相同。例如,如果您的表单具有 ID product-form,则 if 语句应如下所示:if(isset($_POST['ajax']) && $_POST[' ajax']==='product-form')
如果可能的话,我建议使用带有 firebug 扩展的 Firefox,以便可以调试是否有AJAX调用甚至正在制作,以及正在返回的东西。
Make sure the from that is being validated has the same ID that is being used in the
performAjaxValidation
function. For example if your form has the id product-form, the if statement should look like this:if(isset($_POST['ajax']) && $_POST['ajax']==='product-form')
If possible I recommend using Firefox with firebug extension so that you can debug whether the AJAX call is even being made, and what is being returned.