Issue with javascript escape, encodeURI and encodeURIComponent
My application sends data from javascript to my servlet using ajax POST request and that data contains special characters as well. I am sending this data after executing javascript escape()
over the data as my content can also contains URL's.
The problem is that I do not get correct data at my servlet end and I am suspecting that escape
is creating the issue.
I tried following in my javascript code :
alert(escape("»"));
alert(unescape(escape("»")));
alert(encodeURI("»"));
alert(decodeURI(encodeURI("»")));
alert(encodeURIComponent("»"));
alert(decodeURIComponent(encodeURIComponent("»")));
I do not get correct alert when I am unescaping the escape string, As seen by the code, I have also tried using encodeURI, encodeURIComponent and their respective decoding methods.
How should I send the data from javascript so that all of the special character and other part of the content (like URL's) are received properly.
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
是问题,将其更改为UTF-8,现在工作正常。
链接地址: http://www.djcxy.com/p/26520.html上一篇: encodeURI /转义