Encoding Problems . By default, the use of UTF-8, if you find that the object can not be found, may be JS input in the Chinese, while the JS encoding format may be gb2312, open JS available notepad, save as UTF-8 format documents.
Data obtained through XMLHttpRequest, the default character encoding is UTF-8, if the front-end page is gb2312 or other encoding, the obtained data is garbled. Through XMLHttpRequest, post data is also UTF-8 encoding, if the background is gb2312 or other encoding will also appear garbled.
CacheProblem
Due to the cache Processing Mechanism of IE, the first accessed content is always returned every time a dynamic page is accessed through XMLHttpRequest. The solution is as follows:
1. The client is resolved by adding random strings. For example:
VaR url = 'HTTP: // www.bothv.com /';
URL + = '? Temp = '+ new date (). gettime ();
URL + = '? Temp = '+ math. Random ();
2. Disable caching in HTTP headers. For example:
HTTP:
<Meta http-equiv = "Pragma" content = "no-Cache"/>
<Meta http-equiv = "cache-control" content = "no-cache, must-revalidate"/>
<Meta http-equiv = "expires" content = "Thu, 01 Jan 1970 00:00:01 GMT"/>
<Meta http-equiv = "expires" content = "0"/>
PHP:
Header ("expires: Thu, 01 Jan 1970 00:00:01 GMT ");
Header ("cache-control: No-cache, must-revalidate ");
Header ("Pragma: No-Cache ");
ASP:
Response. expires = 0
Response. addheader ("Pragma", "No-Cache ")
Response. addheader ("cache-control", "No-cache, must-revalidate ")
JSP:
Response. addheader ("cache-control", "No-Cache ");
Response. addheader ("expires", "Thu, 01 Jan 1970 00:00:01 GMT ");
3. Add:
XMLHttpRequest. setRequestHeader ("If-modified-since", "0 ");
XMLHttpRequest. Send (null );
Ajax cache and encoding are not difficult to solve. The following is a solution.