gpt4 book ai didi

javascript - 从tinymce发布数据时,它不使用Codeigniter存储数据库

转载 作者:行者123 更新时间:2023-12-02 23:40:36 24 4
gpt4 key购买 nike

我正在使用 tinymce 在 CodeIgniter 中发布数据,但在某些情况下无法从 tinymce 编辑器获取数据能够获取数据并将其存储在数据库中,但大多数时候无法获取数据。我提供了我使用过的jquery代码和ckeditor脚本,请让我知道如何获取数据

$content = strip_tags(trim($this->db->escape_str($this->input->post('content'), " ")));
<script type="text/javascript">
$(document).ready(function () {
if($("#content").length > 0){
tinymce.init({
selector: "textarea#content",
theme: "modern",
height:300,
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"
],
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | l ink image | print preview media fullpage | forecolor backcolor emoticons",
style_formats: [
{title: 'Bold text', inline: 'b'},
{title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
{title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
{title: 'Example 1', inline: 'span', classes: 'example1'},
{title: 'Example 2', inline: 'span', classes: 'example2'},
{title: 'Table styles'},
{title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
]
});
}
});
</script>
<script>
$(function() {
$('#edit_article').validate({
rules: {
"title": {
required: true
},
"content":{
required: true
},
"metatitle":{
required: true
},
"metadesc":{
required: true
},
"metakey":{
required: true
},
"metah1":{
required: true
},
"metaimage":{
required: true
},
"seourl":{
required: true
}
},
messages: {
"title": {
required: "Please Enter Title"
},
"content": {
required: "Please Enter Content"
},
"metatitle": {
required: "Please Enter Meta Title"
},
"metadesc": {
required: "Please Enter Meta Description"
},
"metakey": {
required: "Please Enter Meta Keywords"
},
"metah1": {
required: "Please Enter Meta H1 Tag"
},
"metaimage": {
required: "Please Enter Meta Image Title"
},
"seourl": {
required: "Please Enter SEO Url"
}
},
submitHandler: function(form) {
var myForm = document.getElementById('edit_article');
$.ajax({
type: 'post',
url: '<?php echo base_url(); ?>admin/edit_article/<?php echo $article_data[0]->ARTICLEID; ?>',
dataType: 'text', // what to expect back from the PHP script, if anything
cache: false,
contentType: false,
processData: false,
data: new FormData(myForm),
// data: $('#edit_article').serialize(),
success: function(data) {
// alert(data);
var yourval = jQuery.parseJSON(JSON.stringify(data));
var obj = jQuery.parseJSON(data);
// alert(obj);
if (obj.status == 1) {
swal("Good job!", obj.message, "success").then(function(){
window.location.reload();
});
// $('#edit_video')[0].reset();
} else {
swal({
type: 'error',
title: 'Oops...',
text: obj.message
})
}

}
});
return false;
}
});
});
</script>

最佳答案

您有两个选择:

  1. 在 ajax 调用之前将 tinymce 内容保存到其原始文本区域,如下所示:

    tinyMCE.triggerSave(true,true);
  2. 将内容附加到您的表单数据:

    var formdata = new FormData(myForm);
    formdata.append("textarea", tinyMCE.getContent('content'));

关于javascript - 从tinymce发布数据时,它不使用Codeigniter存储数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56098332/

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