问题
Alright, so I have been banging my head for hours on this. Time to turn to the pros.
I am using jquery to post the serialized form.
I have ckeditor on a page, according to their instruction all I have to do is set the post to a variable and it will work. Well it doesn't. $_POST['TEXTAREA_NAME'] is empty.
alright, no problem. I can just use jquery to append the data to the textarea before the post takes place. now all i get is \r\n.
help please, what is the best way to get the data from ckeditor to mysql?
Text are:
<textarea id="content" name="content"><?php if($_GET['act'] == "edit"){ echo getDigestInfo($articleID, "content"); } ?></textarea>
Jquery:
function saveNew(){
$.post("crud/man-digest.php?act=add", $("#edit-content-form").serialize(),
function(data){
$("form .message").append(data);
}
,"json"
);
}
PHP:
$articleID = intval($_POST['id']);
// Perform Update
$article_title = mysql_prep($_POST['title']);
$article_content = mysql_prep($_POST['content']);
$article_system = mysql_prep($_POST['system']);
$article_updated = mysql_prep($_POST['updated']);
$article_datecreated = $_POST['datecreated'];
$query = "UPDATE techdigest SET
title = '{$article_title}',
content = '{$article_content}',
lastupdate = CURDATE(),
system = '{$article_system}',
datecreated = DATE('{$article_datecreated}')
WHERE id = {$articleID}";
$result = mysql_query($query);
回答1:
Well, Feel pretty dumb here.
figured it out.
when updating the textarea it is best to use .html() instead of .append()
works so far!
~~~~wow,
回答2:
Your ajax post gets the content from the wrong textarea. It should be:
$.post("crud/man-digest.php?act=add", $("#content").serialize(),
来源:https://stackoverflow.com/questions/6430262/ckeditor-and-using-post-to-insert-into-mysql