Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Character Encoding not identical between XMLHttpRequest and a form submit

Reply
Thread Tools

Character Encoding not identical between XMLHttpRequest and a form submit

 
 
ebs2002@gmail.com
Guest
Posts: n/a
 
      09-18-2007
I am working with an AJAX Rich-Text Editor that needs to send its text
to a server for different purposes.

Frequently, the RTE will have characters outside of the ISO-8859-1
character set (the one that is failing testing is '-', or '–'
but many other unicode characters are also being processed
incorrectly).

My test scenario is as follows:
1) If I submit '-' through an HTML form as an input value in Firefox,
my servlet recognizes it as a single character, and submits it into my
database properly.
2) If I submit '-' through an XMLHttpRequest submit, my servlet thinks
the character is a string of four separate characters, and I can't
figure out why.

The javascript for (2) :

var xmlhttp = new XMLHttpRequest();
var params="text="+encodeURIComponent("-");
alert(params); // displays 'text=%E2%80%93
xmlhttp.onreadystatechange = requestcomplete;
xmlhttp.open('POST', url, true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-
urlencoded; charset=utf-8");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.setRequestHeader("Connection", "keep-alive");

The same behavior results if I set the charset to ISO-8859-1, or if I
omit it entirely.
I've analyzed the Request Headers for both forms, and they look
identical. Is there anything that Firefox is doing differently than
what my xmlhttprequest object is doing?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
submit 1 form to 2 servers or 2 forms to 2 server (1 form each) on 1 submit abansal.itp@gmail.com Javascript 3 06-23-2007 07:29 AM
character encoding +missing character sequence raavi Java 2 03-02-2006 05:01 AM
Character encoding between Win and *nix pietdejong@gmail.com Java 13 10-28-2004 04:24 AM
Form submit - hitting enter does not trigger Submit button ASP General 2 10-25-2004 03:37 PM
STRUTS-<html:submit> -Hitting enter key does not submit the form Megha Vishwanath Javascript 3 07-20-2004 05:45 AM



Advertisments