如何ajax提交从CKEditor输入的表单文本区域?
我正在使用 CKEditor、jQuery 和 jQuery 表单插件,我想通过提交 CkEditor 表单的内容Ajax 查询。这是我的代码:
<form id="article-form" name="article-form" method="post" action="/myproject/save">
<textarea name="bodyText" style="visibility: hidden; display: none;"></textarea>
<script type="text/javascript">
CKEDITOR.replace('bodyText');
</script>
<a onClick="$("#article-form").ajaxSubmit();">Submit</a>
</form>
不幸的是,Ajax请求似乎没有传递bodyText
参数;
我做错了什么或者我怎样才能实现我所需要的?
谢谢。
I am using CKEditor, jQuery and jQuery form plugin and I would like to submit contents of the CkEditor form via an Ajax query. Here is my code:
<form id="article-form" name="article-form" method="post" action="/myproject/save">
<textarea name="bodyText" style="visibility: hidden; display: none;"></textarea>
<script type="text/javascript">
CKEDITOR.replace('bodyText');
</script>
<a onClick="$("#article-form").ajaxSubmit();">Submit</a>
</form>
Unfortunately, it seems that the Ajax request does not pass the bodyText
parameter;
What did I do wrong or how can I achieve what I need?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您需要首先调用以下命令,以使 CKEDITOR 更新其相关字段..
所以
HTML
和 javascript
you need to first call the following, to make the CKEDITORs update their related fields..
so
HTML
and javascript
这最适合我:beforeSerialize 回调
This works for me best: beforeSerialize callback
如果您使用 jQuery 表单插件,则可以使用 beforeSubmit 选项以获得更优雅的解决方案:
If you use the jQuery form plugin, you can use the beforeSubmit option for a more elegant solution:
就我而言,以下内容对我有帮助,我只是在密封表格之前使用这两行。
In my case the following helped me,i just use these two lines before seializing the form.
我尝试了这样的事情:
首先我必须在 @Html.BeginForm 上放置一个 id = "#myForm" 之后,我将这些放在我使用脚本的脚本部分中:
然后我为我做了类似的事情 =]提交按钮,它对我来说效果很好,不再按两次提交=]
I tried something like this:
First I had to put an id = "#myForm" on @Html.BeginForm afterwards, I put these in my scripts part where in I use the script:
and then I did something like this =] for my submit button and it works fine for me, no more pressing the Submit twice =]
我只是这样做的:
I just did it like this: