简体   繁体   中英

Ckeditor cannot save textarea value using ajaxForm

i try save using ajaxForm :

<script src="ckeditor.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.form.js"></script>
<script type="text/javascript">
$('document').ready(function() {

    $('#form').ajaxForm( {
    target: '#preview', 
        success: function() { 
        } 
    }); 

});
</script>

<form method="post" name="form" id="form" action="save.php">

    <textarea name="content" id="content" class="ckeditor editor" style="width:400px; height:100px;"></textarea>
    <input type="submit" value="Submit" class="submit"/>

</form>

The problem is when im using ckeditor the textarea value cannot save into db, did i miss something ?

Where's ckeditor?

Init ckeditor like this

CKEDITOR.replace('content');

If you still can't submit data by ajaxForm, try to get data from ckeditor and submit by general ajax

var data = CKEDITOR.instances.content.getData();
$.post('url'
, { data : data }
, function(data) {
    //do something
});

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM