In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article Xiaobian introduces in detail for you "jQuery request transmission Chinese parameter garbled how to solve", the content is detailed, the steps are clear, the details are handled properly, I hope that this "jQuery request transmission Chinese parameter garbled how to solve" article can help you solve doubts, the following follow the editor's ideas slowly in-depth, together to learn new knowledge.
The menu is as follows:
The code is as follows:
Var url = "${basePath} / institutionConfig/getDepartmentByCenter.do?param=" + center;$.get (url, function (data) {var list = data.data; for (var I = 0; I < list.length; iTunes +) {departmentSelector + = "" + list [I] + ";} $(" # accountDepartmentAdd ") .html (departmentSelector);})
I use $.get (url, callback) to send the request to the backend. Since the parameters are sent directly in GET mode, the browser uses URL encoding to encode the parameters, and the parameters obtained by the backend are:
As you can see, what param receives is garbled. So I carried out further processing, that is, transcoding:
String center = new String (param.getBytes ("iso8859-1"), "utf-8")
What is received in this way is Chinese.
However, this practice went so far as to report an error in the test environment. After analyzing the reasons, it was found that the test environment received correct Chinese, but it was wrong after transcoding. Therefore, the solution should be the request to change the page. Because the parameters caused by using the GET method are encoded, the POST request is changed to the POST request, and the original data is submitted:
Var url = "${basePath} / institutionConfig/getDepartmentByCenter.do"; $.ajax ({url: url, data: {"param": center}, dataType: "json", type: "POST", success: function (data) {var list = data.data; for (var I = 0; I < list.length; iTunes +) {departmentSelector + = "" + list [I] + ";} $(" # accountDepartmentAdd ") .html (departmentSelector);}) After reading this, the article "how to solve the garbled code of Chinese parameters in jQuery request transmission" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it to understand it. If you want to know more about related articles, welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.