For anyone else who had a similar issue, here is my solution:

Took a look at the jQuery serialize function, found my way to param
function, and found the best method to encode or escape a datastring
to be sent via ajax is to use encodeURIComponent(string).replace(/%20/
g, "+");

peace

On May 7, 5:57 pm, Richard W <[EMAIL PROTECTED]> wrote:
> Hi There
>
> I have been struggling to correctly format a datastring to be sent via
> POST that may contain 'invalidcharacters'. I am trying to send text &
> html via ajax post, and this has been achieved mainly due to
> Javascript's escape() function. For example, to send the ampersand
> (&), escape() is used to convert the character to it's (8bit?) value.
> For the most part the escape function correctly formats the data
> string, but there are certaincharactersthat will not be escaped, and
> will be processed literally, eg: the plus (+) character.
> I assume the reason why I cannot send the + char as part of the data
> string, is because if the + is used in the url it is seen as an
> escaped space character.
> Without completely re-working my system, is there any possible way of
> sending all data literally in a data string using $.ajax via post?
>
> I'm using the following code:
> $.ajax({
>                 type: "POST",
>                 url: '/cms_page_manager/savepage',
>                 data: dataString,
>                 error: function(XHR, status, error) {
>                 },
>                 success: function(msg){
>                 }
>          });
>
> Any suggestions would be greatly appreciated. I wish I had some more
> experience with character handling, right now i'm about to pull my
> hair out!
> Many thanks in advance.

Reply via email to