gpt4 book ai didi

php - 无法将 Summernote 值存储到数据库中,它返回 [object Object]

转载 作者:行者123 更新时间:2023-12-01 07:50:41 25 4
gpt4 key购买 nike

我尝试使用ajax/jquerysummernote值存储到数据库中,但它只是将该值发送到数据库字段---- -> [对象对象]

HTML:

<div class="form-group">
<label for="description">Desciption</label>
<textarea name="description" id="description" class="summernote"></textarea>
</div>
<div class="text-right">
<a href="#" class="btn btn-primary" id="publish">Publier</a>
</div>

Js文件:

$("#publish").on('click', function(e){
e.preventDefault();
var description = $('textarea[name="description"]').html($('.summernote').code());

$.ajax({
url : 'ajax/newpost.php',
data : 'description=' + description,

success : function(data){
alert(data);
location.reload();
}
});
});

newpost.php

    require_once('../config/connect.php');      

$description = $_GET['description'];



$stmt = $PDO->prepare("INSERT INTO `forum_posts` (`description`) VALUES(?)");
$stmt->execute(array($description));

if($stmt){
echo "done ......................";
}else{
echo "error ..................";
}

最佳答案

您应该将 $('textarea[name="description"]').html($('.summernote').code() 替换为 $('textarea[name ="描述"]').val()

关于php - 无法将 Summernote 值存储到数据库中,它返回 [object Object],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30384054/

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