Home > Article > Web Front-end > A quick solution to Ajax submission of garbled characters under IE
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='" + item.city + "' selected = 'selected'>" + item.city + "</option>").appendTo($("#city")); }else{ $("<option value='" + item.city + "'>" + item.city + "</option>").appendTo($("#city")); } }); } }); }
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!