0

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);
Jason Spick
  • 6,028
  • 13
  • 40
  • 59

2 Answers2

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,

Jason Spick
  • 6,028
  • 13
  • 40
  • 59
0

Your ajax post gets the content from the wrong textarea. It should be:

$.post("crud/man-digest.php?act=add", $("#content").serialize(),
konsolenfreddy
  • 9,551
  • 1
  • 25
  • 36
  • as mentioned above, I'm serializing the form, not just the field. I suppose I should have clarified that. anyway found the problem, need to use .html and not .append to update text area. – Jason Spick Jun 21 '11 at 18:53