如何在Ajax Angular中保存ckeditor值?
问题描述:
我在使用Angular AJAX保存数据库中的CKEDITOR值时遇到了问题。我不知道它是一个角度问题还是PHP。顺便说一句,我在我的应用程序中使用CodeIgniter 3。如何在Ajax Angular中保存ckeditor值?
这里有一点我的代码,我希望你明白,我有:
我CKEDITOR: 在这里,我保存了协议
这里的AJAX保存:
$scope.saveContent = function() {
$scope.totals = [{
'subtotals' : computeGrandTotal(),
'vat_rate' : quoteList.vat_rate,
'grandtotal': computePercentage()
}];
$http({
url: "<?php echo base_url('index.php/tutorial/submitQuotation'); ?>",
method: 'POST',
data: $.param({
quotation: $scope.quoteHeader.items,
msc: quoteList, //here goes the agreeement content
totals: $scope.totals
}),
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function(data){
alert('Data successfully inserted!');
}).error(function(){
alert('Error Occured!');
});
}
而在我的模型中,我这样做:
$sqlInsertQuotationAgreement = "INSERT INTO quotation_agreement SET quoatation_id = " . (int)$quotationID . ", agreement = '" . $agreement . "'";
$queryInsertQuotationAgreement = $this->db->query($sqlInsertQuotationAgreement);
而当我检查我的开发者控制台时,我得到一个错误,因为我的CKEDITOR中的值以HTML格式呈现,而不是代码中。我试图使用stripslashes()和$ this-> db-> escape(),但仍然错误。
你能帮我吗?
答
好吧,我解决了我的错误。下面是我在查询中所做的:
$sqlInsertQuotationAgreement = "INSERT INTO quotation_agreement SET quotation_id = " . (int)$quotationID . ", agreement = \"" . htmlspecialchars($agreement) . "\"";
好,我试图用这个功能,它得到我的HTML数据:'用htmlspecialchars()'但是我得到这个错误:'您的SQL语法错误;检查与您的MySQL服务器版本相对应的手册,以获得正确的语法,以便在物料和碎石以及机器和设备附近使用,并且通常应该在'1号线' – Jerielle