## The operating environment of this tutorial: windows7 system, jquery1.10.0 version, Dell G3 computer. Recommendation:Methods to solve garbled jquery parameters: 1. Transcode through "new String(param.getBytes("iso8859-1"), "utf-8");"; 2. The request to modify the page is Just POST request.
jQuery sends a request to transmit garbled Chinese parameters
The needs I am doing recently involve For cascade query, you need to query the lower-level drop-down box list based on the content of the upper-level drop-down box. Because there are only two levels of cascading, and the data in the table will hardly be changed later, the table I designed stores directly Chinese. The menu 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; i++) { departmentSelector += "<option value='" + list[i] + "' "; if (department && list[i] == department) { departmentSelector += "selected='selected'"; } departmentSelector += ">" + list[i] + "</option>"; } $("#accountDepartmentAdd").html(departmentSelector); });
<br/>
You can see that the param received is garbled. . So I performed further processing, that is, transcoding:String center = new String(param.getBytes("iso8859-1"), "utf-8");
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; i++) { departmentSelector += "<option value='" + list[i] + "' "; if (department && list[i] == department) { departmentSelector += "selected='selected'"; } departmentSelector += ">" + list[i] + "</option>"; } $("#accountDepartmentAdd").html(departmentSelector); } });
<br/>
The above is the detailed content of How to solve the jquery parameter garbled problem. For more information, please follow other related articles on the PHP Chinese website!