Home > Web Front-end > JS Tutorial > How to deal with Ajax submission garbled code under IE

How to deal with Ajax submission garbled code under IE

php中世界最好的语言
Release: 2018-04-03 15:44:59
Original
1382 people have browsed it

This time I will show you how to deal with garbled codes submitted by Ajax under IE. What are the precautions for dealing with garbled codes submitted by Ajax under IE. The following is a practical case, let's take a look.

Haha, after trying so many things, encodeURIComponent still works! ! ! !

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 seems to be irrelevant Use, o(︶︿︶)o Oh, it’s better to rely on yourself~~

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

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Ajax+mysq realizes the three-level linkage list of provinces and municipalities

Ajax transmits Json and xml data Detailed explanation of the steps (with code)

The above is the detailed content of How to deal with 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