With AJAX, I'm having problem when submitting text that includes ascii characters (that are not readily available on the keyboard, e.g., ©, ñ, ®, ™). I found that these characters are sent/submitted in UTF-8, which is the default charset when using the send() function of Microsoft.XMLHTTP ActiveXObject, and appear differently when inserting into the database. The ñ comes as Ã±, the © comes as Â©, and so on. There is always this Â or Ã character that is stored together with original character. If I have a char field in the database with a length of 1, it is apparent that this kind of encoding is a problem.
Here is a sample code that I use:
oXMLHTTP = new ActiveXObject('Microsoft.X
onreadystatechange = showSubmitResult;
sParams = 'txtText=' + document.forms.txtText.
A documentation I found on MSDN (http://msdn2.microsoft.com/en-us/library/ms755436.aspx
, you might find it funny that IE7.0 detects this Microsoft website as a phising website) says that on the setRequestHeader method, I should include a charset attribute to override the default utf-8 encoding so I tried this:
Both didn't work.
I could just include the data to be submitted in the sUrl parameter of the open() method and retain the original encoding (iso8859-1) but there's another problem: the maximum URL length is 2083 on IE (http://support.microsoft.com/kb/208427/en-us
I just want to know how I can pass the data thru the send() method while retaining the iso8859-1 encoding.