views:

512

answers:

3

I am using ajax to gather the CKEditor content and submit it to the server. Once I look at it after it is submitted, all the html tags < and > have been converted to their html entities. This is not what I want, as I obviously need to preserve the HTML.

Is there something I did wrong?

+2  A: 

A couple of questions:

  1. Which AJAX library are you using?
  2. What method are you using to fetch the content from CKEditor?

I use jQuery + validate (form validation plugin) for my form submissions.

The textarea to which CKEditor is bound is named body.

For some weird reason when I submitted the form, the content wasn't being submitted at all. Looking into the HTML I found that the textarea wasn't being populated by CKEditor (don't ask me why).

What I did was to just prior to submission, manually grab the data from CKEditor and stash it into the textarea. A single line of jquery should suffice.

$( '#body' ).val( CKEDITOR.instances.body.getData() );

And then proceed with the form submission normally. jQuery has a very good data serialization method - a function called serialize(), which I use to convert the entire form's data into a string. At the PHP end, this string is auto-converted into members of the $_POST array.

You should try the same approach and see if it works for you.

If you're still stuck, post your code here.

Cheers, m^e

miCRoSCoPiC_eaRthLinG
In the end I realized that my server was not saving the data at UTF-8 even though ajax was sending it this way. So, I fixed that and the data saves correctly.
Nic Hubbard
Cool. Problem solved :)
miCRoSCoPiC_eaRthLinG
How did you make your server save the data at UTF-8
AnApprentice
A: 

Correct is to set up in config this entities : false

Tom
A: 

In the end I realized that my server was not saving the data at UTF-8 even though ajax was sending it this way. So, I fixed that and the data saves correctly.

Nic Hubbard