Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Special Charater

Status
Not open for further replies.

pgr

IS-IT--Management
Feb 28, 2002
24
0
0
PT
Hello
I'm a starting on AJAX and I'm having a problem that I can't solve.

I have a .htm file with a form that calls a javascript file that in turn calls a .asp file to insert a new record on a SQL table:

default.htm -> file.js -> file.asp

The form as a text input object where I write the name of a new user and my problem is with accents like õ or ã.

The file.js receives the name of the user correctly. The problem is when it sends the name to the file.asp. It does it like this:
xmlHttp.open("GET","file.asp?q=joão&sid="+Math.random(),true);

on the asp file the line:

response.write( Request.QueryString("q"))

shows me the following on the screen: jo?
instead of joão as it should.

On the asp file I've already add a line like this to try to solve the problem but with no luck:

Response.Charset="ISO8859-1"

Can anyone help me?

many thanks




 
You will need to escape your data (each value in the key/value pair you submit in the GET request) before sending it as part of a GET request (to your server).

To send just the q param, you might do it like this:
Code:
var q = "joão"; // set this to a known, failing, value for testing
q = escape(q);
xmlHttp.open("GET","file.asp?q=[!]"+q+"[/!]&sid="+Math.random(),true);

Also, if you are using sid as a "cache buster" (for IE6 etc), then consider this wonderful wiki entry on how to solve the problem properly (or switch to using POST). This is really important if you want to build your AJAX stuff to scale (restful urls for caching etc) [smile]

XMLHttpRequest (check out the "Known Problems - Caching" section).

Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Worked great Jeff!!

Many thanks :)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top