I encountered a problem today, regarding the problem of garbled characters when transmitting Chinese in an ajax request.
The following code:
function UpdateFolderInfoByCustId(folderId, folderName , custId) {
$.ajax({
) type: "Post",
contentType: "application/x-www-form-urlencoded; charset=utf-8",
url: " http://localhost/CRM/Ashx/HandKBSucessCustomer.ashx?Method=UpdateCustomerByCustId&folderId="
folderId "&folderName=" encodeURI(encodeURI(folderName)) "&custId=" custId,
success: function (msg) {
;
If you just pass "&foderName=" folderName in the above code, the Chinese characters will be garbled. If converted twice through encodeURL, the Chinese character encoding will become similar to
The format of “test믕”. After converting to this format, transcode when retrieving, as shown below:
Copy code
The code is as follows:
}
}
}
After this conversion, the transmitted Chinese characters can be obtained.