The garbled problem of submitting fetch data during AJAX development

Source: Internet
Author: User
Tags string
ajax| Process | data | issues


These two days are continuing my Ajax journey. have been grasping at the pace.

The day before yesterday to use Ajax to submit form form to the server, get form information content appears garbled, temporarily unable to solve. There is a conclusion on the Internet that is the reason for application/x-www-form-urlencoded coding, I reckon. are looking for a solution to the problem.

Let's discuss the discussion together.

Add: In the background by using UTF8 transcoding method can solve the Chinese garbled problem. This method is submitted for form forms, and the encoding is done on the server. The code is as follows:



  FORM.JSP:


<%@ page contenttype= "text/html; charset=gb2312 "%>

form submission Test

<TD width= "height=" > Username:
<TD width= "height=" >
<TR align= "center" >
<TD height= "colspan=" 2 ">


  FORM_HANDLE.JSP:

<%@ page contenttype= "text/html; charset=gb2312 "language=" java "errorpage=" "%>
<%
String username = new String (Request.getparameter ("username"). GetBytes ("Iso-8859-1"), "UTF8");
String Password = request.getparameter ("password");
System.out.println ("User name:" +username);
System.out.println ("Password:" +password);
Out.println (username+ "|") +password);
%>



In addition, some netizens react to generate XML documents containing Chinese content to return to the client will also appear garbled problem. It is recommended to change the encoding of XML documents to UTF8 try.




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.