Thursday, June 21, 2007

Javascript URL encoding

If you are using AJAX or something else to communicate via url, you can use the javascript function "escape()" to encode parts of the URL. I list some of the characters that are encoded and some that are not:

Encoded: ! # $ % ^ ( ) = [ ] { } ; " \ ' ? / ,
Not encoded: underscore @ & * - + .

You can also use the javascript function "encodeURI". It has a different set of encoded characters:

Encoded: ` ^ [ ] { } " < > \
Not encoded: underscore tilde ! @ # & $ * ( ) = + , . : ; ' / ?

No comments: