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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.