To: AJAX Chinese lessons

Related Tags:

  Recently wrote a ajax, testing has been no problem, the results into other computers, which have three to five computer Display garbled, the enquiries about, there is a conclusion, very good! Ajax return to the original values are utf-8 decoder , 

  AJAX Chinese issues fall into two broad categories: 
  1) Send in the path of Chinese parameters in the server parameter values of the receiver is garbled 

  For example: 
  Var url = "a.jsp? Name = Li"; 
  XmlHTTP.open ( "post", url, true); 
  The solution: 
  Javascript provided by the use of the escape () or encodeURI () method 
  For example: 
  Client: 
  Var url = "a.jsp? Name = Li"; 
  Url = encodeURI (url); 
  Url = encodeURI (url); / / twice, it is key to [specify why, I do not know] 
/********************************************/
  It was also written var url = "a.jsp? Name = escape (" Li ")"; 
  EncodeURI similar functions and methods. 
/********************************************/
  XmlHTTP.setrequestheader ( "cache-control", "no-cache"); 
  XmlHTTP.setrequestheader ( "Content-Type", "application / x-www-form-urlencoded"); 
  XmlHTTP.setrequestheader ( "contentType", "text / html; charset = uft-8") / / designated sent the data coding format 
  XmlHTTP.open ( "post", url, true); 
  Server: 
  String name = request.getParameter ( "name"); 
  Name = java.net.URLDecoder.decode ( "name", "UTF-8"); 
  2) to return the responseText responseXML or the value of the presence of Chinese is garbled 
  Cause: AJAX in the receiving responseText responseXML or the value of time in accordance with the UTF-8 format decoding, if the server of the data is not sent UTF-8 format, or to receive responseText responseXML value is likely to hash. 
  The solution: send data in the server specified format: 
  In jsp file: 
  Response.setContentType ( "text / text; charset = UTF-8 ");// txt is the return of text files 
  Or 
  Response.setContentType ( "text / xml; charset = UTF-8 ");// return to the xml 

  Aggregate: 1) ajax the default data format for utf-8, the use of javascript provide escape () or encodeURI () method. Reception in the server when to use UTF java.net.URLDecoder.decode (""," -8 ") method for decoding. 
  2) xtmlhttp return of the default character encoding data is utf-8, so the client to the server when sending data, but also use utf-8 encoding 
  If the hash is still unresolved problems, then you try to jsp, htm, java document with UTF-8 encoding format. 
  In short: after-use interactive data utf-8 encoded on the trip. 

  3) If asp beginning to show normal refresh hash, and the following statements 

  <% @ LANGUAGE = "VBSCRIPT" CODEPAGE = "936"%> 

  <meta Http-equiv="Content-Type" content="text/html;charset=gb2312"> 

<%
  Response.Charset = "GB2312" 
  Session.CodePage = 936%> 




Related articles:

Tips will enter the pages of the web site as a code Home
  <body Onload="myhomepage();">    <script Language="javascript">    Function myhomepage () (    This.homepage.style.behavior = 'url (# # default homepage)'; this.homepage.sethomepage ( 'http://www.webjx.com/');&n...
Tu AS entry Grammar Guide chapter
  AS syntax chapter  -----------------------------------   I read the first tutorial - the basis of articles, now you AS a certain position the existence of the concept of the right?    If not, then to review what it    Tu AS entry Guide series - based on artic...
JavaScript Application examples: a statistical point of
  Ff not to default status    Opera9 test pass    Ie6 test pass    This is what used to statistical analysis to improve user habits site layout.    Play only read the small things, so many places not very satisfactory.    Save () method is...
Flash: loadMovie / loadMovieNum explain the use of
  Technology Forum in the area of question for so long, found that these two functions we asked more frequently today, here with my own experience, to write a detailed guide, we hope that the future can use to bring help.    First, loadMovie ( "url", target [method])  ...
The birth of the Internet also have 15 of the 15 sites change the world
  Matrix wrote, "the birth of the Internet also 15, during the numerous websites. Guardian article sorted out on the Internet site of landmark significance: 15 changed the world website. Involved in all aspects, from commercial The web-sites such as eBay and Amazon collaboration of the com...