gpt4 book ai didi

javascript - 将 Tinymce 编辑器与 AJAX 结合使用

转载 作者:行者123 更新时间:2023-12-03 08:54:45 24 4
gpt4 key购买 nike

我在程序中使用tinymce作为文本编辑器,因此在表单中添加数据并尝试使用AJAX保存后,除了使用tinymce编辑器的文本区域之外,所有字段都正常保存,这是我的代码,我的问题是(内容)文本区域:

<script type="text/javascript">
tinymce.init({
selector: "textarea#content",
theme: "modern",
plugins: [
"advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
"searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
"save table contextmenu directionality emoticons template paste textcolor"
],
content_css: "css/content.css",
toolbar: "link image | fontselect fontsizeselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | print preview media fullpage | forecolor backcolor emoticons"
});
</script>

<script type="text/javascript">
$(document).ready(function(){


$('#submit').click(function(){
$('#result').fadeOut("fast");
$('#wait').fadeIn("slow").delay(1000);
var title = $("input#title").val();
var content = $("textarea#content").val();
var student_year = $("select#student_year").val();
var student_group = $("select#student_group").val();

var direction = $("input#direction").val();

var dataAll = { title:title,
content:content,
student_year:student_year,
student_group:student_group
}
$.ajax({
url: direction,
type : "POST",
data : dataAll,
dataType :"html",
success : function(msg){
$('#wait').fadeOut("fast");
$('#result').fadeIn("slow");
$('#result').html(msg)

}

});

});

});
</script>

最佳答案

请尝试在 $('#submit').click(function(){:

之后添加此行:

tinymce.triggerSave();

关于javascript - 将 Tinymce 编辑器与 AJAX 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32556198/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com