yii CActiveForm 通过 AJAX 提交 [英] yii CActiveForm submitting by AJAX

查看:16
本文介绍了yii CActiveForm 通过 AJAX 提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码创建表单:

I create form using the following code:

<?php $form=$this->beginWidget('CActiveForm', array(
    'id'=>'contacts-form',
    'enableAjaxValidation'=>false,

)); ?>

有没有办法通过 AJAX 提交表单?请记住,我不是在谈论 AJAX 验证.

Is there any way to submit the form by AJAX? Remember not I am not talking about AJAX validation.

推荐答案

这个辅助 ajaxSubmitButton 函数并不是非常有用,特别是因为它使用 jquery.ajax() 而没有使用 jquery 1.5+ 中的Promise 接口",所以你必须通过成功回调处理响应.如果他们只使用 jquery.submit(),这会更清晰.老实说,你最好自己动手.

This helper ajaxSubmitButton function isn't terribly useful, especially since it uses jquery.ajax() without using the "Promise interface" in jquery 1.5+, so you have to process the response through the success callback. This would have been cleaner if they just used jquery.submit(). You're better off just rolling your own, honestly.

我感到失望的是,没有任何(相对流行的)Bootstrap 集成(如 Yii-Bootstrap 或 YiiBooster)在生成用 ajax 响应数据刷新自己的表单方面提供了很多东西(我不是在谈论验证).我经历了学习和学习的所有麻烦采用一个框架,但最终还是用 html/js/css 编码我自己的前端演示和逻辑......哦,好吧.

I'm disappointed that none of the (relatively popular) Bootstrap integrations like Yii-Bootstrap or YiiBooster offer much of anything in terms of generating forms that refresh themselves with ajax response data either (I'm not talking validation). I go through all the trouble of learning & adopting a framework, only to end up html/js/css-coding my own frontend presentation and logic anyway... Oh well.

我仍然是 Yii 的爱好者,主要是因为他们的 gii 生成器和对具有行为"的准混合模式的支持.它导致后端的代码干净,但该框架在前端和前端有一些工作要做.查看渲染.他们的CHtml"库现在确实没有削减它.

I'm still a Yii enthusiast, mostly due to their gii generator and support for quasi-mixin patterns with "behaviors". It leads to clean code on the backend, but the framework has some growing to do on the frontend & view rendering. Their "CHtml" library really isn't cutting it right now.

这篇关于yii CActiveForm 通过 AJAX 提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆