Home > Web Front-end > JS Tutorial > A quick solution to Ajax submission of garbled characters under IE

A quick solution to Ajax submission of garbled characters under IE

亚连
Release: 2018-05-23 15:05:28
Original
1453 people have browsed it

Now I will bring you a quick solution to Ajax submission garbled code under IE. Let me share it with you now and give it as a reference for everyone.

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

The above is what I compiled for everyone. I hope it will be useful to you in the future. Everyone is helpful.

Related articles:

Ajax form asynchronous file upload example code

Cascade operation of drop-down menu

Ajax realizes three-level cascading of provinces and municipalities

The above is the detailed content of A quick solution to Ajax submission of garbled characters 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