tags:

views:

198

answers:

1

I have this code wich works with no errors when sending "simple text" through Ajax post. But when i want to send "html" to the server, my code will fail sometimes.

            var message = tinyMCE.activeEditor.getContent();

            if(message.length > 0)
            {
                message = Base64.encode(message);
                tinyMCE.activeEditor.setContent('');

                var parameters = 'message=' + message;
                var url = "ChatResponse.aspx";
                ajaxPost.open("POST", url, true);
                ajaxPost.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                ajaxPost.setRequestHeader("Content-Length", parameters.length);
                ajaxPost.setRequestHeader("Connection", "close");
                ajaxPost.send(parameters);
            }

Will not fail for asdasdasdasd [base64:] YXNkYXNkPHN0cm9uZz5hc2Rhc2Q8L3N0cm9uZz4=

but will fail for

aa [base64:] YTxzdHJvbmc+YTwvc3Ryb25nPg==

What is wrong ?

A: 

It is not being encoded before being sent. I believe TinyMCE has a method that allows you to get the encoded content. You may also want to try taking the content from the textarea using the value property.

Nick Berardi
Does getContent() not do that?
Darryl Hein
If I remember right tinymce has two methods to get encoded and unencoded.
Nick Berardi