Get the App
SLTechnology News&Howtos  ›  Development  › 

What to do if Ajax submits garbled codes under IE

Shulou Source: shulou.com Published: 2022-06-03 20:15:44 10月05日 Update

This article will explain in detail how to submit garbled codes for Ajax under IE. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

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 ('failed to load city list!');}, success: function (msg) {$("# city") .empty () $.each (eval (msg), function (I, item) {if (item.city = = city) {$("" + item.city + ") .appendTo ($(" # city "));} else {$("+ item.city +") .appendTo ($(" # city "));}});});})

Another method of adding contentType on the Internet doesn't seem to work. Alas, it's still reliable on your own.

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

This is the end of the article on "how to submit garbled codes in Ajax under IE". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Articles garbled code how to do more good practical location content city measures articles methods knowledge or Chinese characters protection reference help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Apple Xiaomi Huawei Shulou Information