Jump to content

autosave to mysql DB with Jquery with Ckeditor


nickcoupland

Recommended Posts

Hi Everyone,

Not sure where i was meant to post this but i thought this area was the best for it.

Just having one issue and is probably a simple fix. I am using the ckeditor in a form that push the content to a mysql database using php. I am also using a jquery function that autosaves using ajax every 20 secs. the autosave function put all the content into the DB except for the textarea that has the ckeditor applied to it. If i submit the the form by pressing the sumbit button everything works how it should, the problem only occurs when the javascript tries to do the saving for me. Heres the javascript code:

 

   
<script type="text/javascript">
   $(document).ready(function(){         
      autosave();
   });
   
   function autosave() 
{ 
    var t = setTimeout("autosave()", 20000); 
    var title = $("#txt_title").val(); 
    var text = $("#txt_content").val();
    var author = $("#txt_author").val();
    var issue = $("#txt_issue").val();
    var category = $("#txt_category").val();
    var date = $("#txt_date").val();
    var image = $("#txt_image").val(); 

    if (title.length > 0 || content.length > 0) 
    { 
        $.ajax( 
        { 
            type: "POST", 
            url: "autosave.php", 
            data: "id=" + <?php echo $article_id ?> 
+ "&title=" + title + "&text=" + text + "&author=" + author + "&issue=" + issue + "&category=" + category + "&date=" + date + "&imageURL=" + image, 
            cache: false, 
            success: function(message) 
            { 
                $("#timestamp").empty().append(message); 
            } 
        }); 
    } 
}
   </script>   

 

And here is the code on the textarea:

<textarea class="ckeditor" name="text" id="txt_content" cols="50" rows="5"></textarea>

 

I had this working with tinyMCE but i would prefer to use ckeditor as it works better with the system im making. Any help would be great.

Thanks

Nick

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.