(1) Ajax Chinese problems
In the process of passing a parameter, Chinese characters are encoded in a UTF-8 way.
var url = encodeuri (URL); Note: two times in IE encodeURI
For example, "medium" the Chinese character, will be transmitted by%E4%B8%AD.
On the server side, after taking the parameters. You have to decrypt it.
String old = Request.getparameter ("name");
Then decode it on the server side
String name = Urldecoder.decode (old, "UTF-8");
(2) Ajax cross-domain problem
Same domain: If the HTML code and server code are called the same domain on the same server.
Cross-domain: If the HTML code and server code are not on the same server, it is called Cross-domain.
Cross-domain issues, JavaScript are not allowed to invoke other pages ' objects across domains for security reasons.
Through the IFRAME to achieve a very poor security, easy to lead to viruses and Trojans.
Let the page end program first access the same domain server-side agent, through the agent and remote server
Program interaction. Because the agent is written in Java, all programs can access any remote server.
Client:
function Converurl (URL) {
if (url.substring (0,7) = = "http://") {
Url.replace ("?", "&");
Url= "Proxy?url" +url
}
return URL;
}
Proxy Server side:
(1) Get the client URL and parameter information
(2) Connect by url = new URL (url.tostring ());
URLConnection connection = Connect.openconnection ();
OutputStreamWriter paramout = new OutputStreamWriter (Connection.getoutputstream ());
To access the remote server code, and finally on the proxy server to send processing data through the form of streaming to the browser.
(3) Ajax cache problem
in Ajax the buffer information for the same IE read browser is not interacting with the server. On the request address
Plus timestamp, cheated the browser, so that the request address is not the same, do not read the buffer. Send a new request.
var timestamp = new Date ();
if (Url.indexof ("?") >=0) {
url=url+ "&date" +timestamp;
&NBSP} else {
url= url+ "? Date" +timestamp;
&NBSP
This guarantees that the browser is not the same every time the request is requested.