views:

23

answers:

1

if encoding using escape(data) in javascript, how to decode it in server side?

I use ajax to post encoding data with escape javascript function, how can I decode it at the server side with classic asp

+1  A: 

If you are passing arguments in URL (get method), do not use encode().. use encodeURI() function instead. Now, the data (I mean the parameters you pass) comes decoded automatically.

echo
ar phone = document.getElementById("phone").value; var url = "/cgi-local/lookupCustomer.asp?phone=" + escape(phone); xmlhttp.open("get", url, true); xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded'); xmlhttp.send(null); if phone = "Ô", i will get "?" in lookupCustomer.asp
Jason
use like this, var url=encodeURI("/cgi-local/lookupCustomer.asp?phone=Ô"); xmlhttp.open("get", url, true); ......
echo