1、在客户端使用 encodeURIComponent 方法对中文参数进行编码,保证其采用 UTF-8 编码传输。
2、然后在ASP中使用ClassCoding.UrlDecode_JS来转换成中文录入数据库
示例:
JS:hondycms-->login->js->function.js
function getFormData($form) {
var unindexed_array = $form.serializeArray();
var indexed_array = {};
$.map(unindexed_array, function (n, i) {
indexed_array[n['name']] = encodeURIComponent(n['value']);
});
return indexed_array;
}
hondycms-->login->js->contact.js
$("body").on("click", "[type=submit]", function (e) {
e.preventDefault();
editor.sync();
$(this).find("[name=content]").val(editor.html().replaceAll("../UploadFiles/", "UploadFiles/"));
$.ajax({
type: 'POST',
data: JSON.parse(JSON.stringify($.extend({
navid: navid,
ajax: 1
}, getFormData($("form"))))),
dataType: 'json',
success: function (data) {
if (data.stat === 'ok') {
alert(common.ok);
} else {
err(data.msg);
}
}
});
})
ASP:
HCMS->Contact->Update
Content = RequestForm("Content")
Set ClassCoding = New Coding
Content = ClassCoding.UrlDecode_JS(Content)
Set ClassCoding = Nothing |