Showing posts with label XMLHTTP. Show all posts
Showing posts with label XMLHTTP. Show all posts

Tuesday, July 18, 2006

Sending string in xmlhttp in correct string encoding format

Sending string in xmlhttp in a correct character encoding format

Yesterday, we (Shani – one of my team-mate, and I) had a strange problem in character encoding format.

We tried to transfer an xml (string in xml format not the XmlDocument Object) from client side to server side by xmlhttp object, and that xml contained a Hebrew characters.

When the xml arrived to the server side we took the string from the Request object in array of bytes format, then we built a string from this array, and loaded it to an xml object (XmlDocument class).

Then, in the xml property of this object we saw that the xml contain a gibberish in the Hebrew text (probably wrong string encoding format). I tried to add the xml header with the correct encoding declaration, and then to load it to an xml object, but it didn't work.

After a lot of thinking and searching I found the mistake.

I always look on the xml after I convert it from array of bytes to string, and only after I create the all string, I tried to change the string's encoding.

I found that maybe I needed to change the encoding in the beginning of the process, and then use the class System.Text.Encoding.

In this class I found a method that gets strings from array of bytes in UT8-8

encoding (8-bit Unicode Transformation Format).

And everything worked perfect, so next time you will want to send a string in "special" encoding format and to get the same string(in the same encoding format), you should use this method…

Example:



Thursday, July 06, 2006

Make a basic CallBack functionality (using XmlHttp object)

Hi,
It's so easy to implement a basic call back functionality (in asynchronous xmlhttp method) and to use it in your web pages(One of the Ajax implementation).
You just need to use XmlHttp object and to wrap the code with some java script function.

For example:
Code for client side:


And for server side:

And that's all, you have a basic CallBack functionality!