Can anyone give example of how to use CHtml::ajaxbutton
with Yii for posting the elements without form?
相关问题
- Carriage Return (ASCII chr 13) is missing from tex
- Using :remote => true with hover event
- Is there a way to play audio on a mobile browser w
- net::ERR_EMPTY_RESPONSE when post with ajax
- Easiest way to get json and parse it using JQuery
相关文章
- spring boot用ajax发送请求后,请求路径多了controller的路径
- 针对复杂结构的前端页面,如何更好地与后台交互实现动态网页?
- ajax上传图片,偶尔会出现后台保存的图片有错误或者已损坏,请问可能是什么原因造成的?
- 前端 我想知道怎样通过发ajax请求向服务器拿到数据然后分页显示 最好是点击一页就发一次请求
- 接口返回的数据格式如下,请问可以取到level值为2的name数组呢
- 如何通过页面输入账号密码提交给后端
- How to get jQuery.ajax response status?
- Can you run console jobs from yii2-basic?
Quick Example
ajaxSubmitButton()
You need a
data
parameter inside theajaxoptions
To pass the data, you need to add it to your ajax array, e.g.:
In this case, all input type elements in the element with id
dataContainer
would be submitted, and could be accessed via $_POST.Obviously, the JS could be more complicated, you could get values from certain elements, and build your own object, e.g.:
Then, in your controller, you could access
$_POST["field1"]
and$_POST["pageTitle"]
, though I generally tend to access items via CHttpRequest::getParam() as then I can get either POST or GET values, e.g.CHttpRequest::getParam('field1')
More examples of Yii ajax button