I'm trying to use jQuerys ajaxForm ( http://jquery.malsup.com/form/ ) and CKEditor ( http://ckeditor.com ) together but textarea post empty.
HTML Codes:
<form action="test.php" method="POST" class="ajaxformhere">
<textarea class="ckeditor" name="sometext" id="sometext"></textarea>
<input type="submit" value="Send"/>
</form>
Javascript:
<script>
$('.ajaxformhere').ajaxForm({
beforeSubmit: function() {
var textbox = CKEDITOR.instances.sometext.getData();
$('#sometext').val(textbox);
},
success: function(data) {
alert(data);
}
});
</script>
I have no idea why but ckeditor doesn't update textarea element. It posts empty when I try to submit it.
Try to use beforeSerialize
instead of beforeSubmit
event:
$('.ajaxformhere').ajaxForm({
beforeSerialize: function(form, options) {
for (instance in CKEDITOR.instances)
CKEDITOR.instances[instance].updateElement();
},
success: function(data) {
alert(data);
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.