从ckeditor textarea提交ajax表单提交值后未通过邮寄发送 [英] after ajax form submit value from ckeditor textarea is not sent through post
本文介绍了从ckeditor textarea提交ajax表单提交值后未通过邮寄发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在单击按钮上art_title字段值发送到art_save.php页面后,我有一个包含一些文本字段和textarea的表单(ckeditor),但未发送textarea的值.
i have a form having some textfields and a textarea (ckeditor), after onclick button art_title field value is sent to art_save.php page, but value from textarea is not sent.
<script src="ckeditor/ckeditor.js"></script>
function saveArt()
{
var title = document.getElementById('art_title'),
art_title = title.value;
var desc = document.getElementById('art_body'),
art_body = desc.value;
jQuery.ajax({
type: 'POST',
url: 'art_save.php',
data: {
title: art_title,
aut: art_author,
tag: art_tag,
desc: art_body
}
});
return false;
}
html部分
<form method="post" name="art" id="art">
<input type="text" id="art_title" name="art_title" placeholder="Here goes your title"/>
<textarea class="ckeditor" name="art_body" id="art_body"></textarea>
<input type="submit" name="savedraft" id="savedraft" onclick="saveArt();return false;" value="Need more Research ! Save as Draft" class="button"/>
</form>
推荐答案
您可以使用以下方法强制CKeditor更新textarea值:
You can force CKeditor to update the textarea value using:
for (instance in CKEDITOR.instances) {
CKEDITOR.instances[instance].updateElement();
}
此外,您可以将.serialize
用于数据-如果参数更改,则不必维护AJAX代码:
Also, you can use .serialize
for the data - then you won't have to maintain the AJAX code if parameters change:
<script src="ckeditor/ckeditor.js"></script>
function saveArt()
{
for (instance in CKEDITOR.instances) {
CKEDITOR.instances[instance].updateElement();
}
jQuery.ajax({
type: 'POST',
url: 'art_save.php',
data: $("#art").serialize()
});
return false;
}
这篇关于从ckeditor textarea提交ajax表单提交值后未通过邮寄发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文