Home > Backend Development > PHP Tutorial > How to solve Ajax submission garbled code under IE

How to solve Ajax submission garbled code under IE

小云云
Release: 2023-03-19 13:24:01
Original
1494 people have browsed it

This article mainly brings you a quick solution to Ajax submission garbled code under IE. The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. Let’s follow the editor to take a look, I hope it can help everyone.

Add a protective measure to the position of Chinese characters: encodeURIComponent(parentid)

function loadCity(parentid) {
	var city = '${hotel.city}';
	
  $.ajax({
    url: './listCity.jspx?prov='+ encodeURIComponent(parentid),
    type: 'GET',
    dataType: 'JSON',
    timeout: 5000,
    error: function() { alert('加载城市列表失败!'); },
    success: function(msg) {
$("#city").empty();
$.each(eval(msg), function(i, item) {
	if(item.city ==city){
		$("<option value=&#39;" + item.city + "&#39; selected = &#39;selected&#39;>" + item.city + "</option>").appendTo($("#city"));
	}else{
		 $("<option value=&#39;" + item.city + "&#39;>" + item.city + "</option>").appendTo($("#city"));
	}

  
});
    }
  });
}
Copy after login

Another method of adding contentType mentioned on the Internet does not seem to work, o(︶︿︶)o Alas, still You are reliable~~

contentType: 'application/x-www-form-urlencoded; charset=utf-8',

Related recommendations:

Ajax submits the Form form page and will still refresh j solution

Ajax submits the mobile phone number to the database for verification and returns the status value instance details

Ajax form submission and file upload example code

The above is the detailed content of How to solve Ajax submission garbled code under IE. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template