【发布时间】:2015-11-22 05:04:01
【问题描述】:
我有一个编码为 iso-8959-9 的页面。我将 ajax 请求发送到同一页面,同时将一些数据保存到数据库。但它会将字符转换为 utf-8。
我的响应标头与 charset iso-8859-9 看起来不错。但是 Request Header、Content-Type 数据总是 UTF-8。请参考下面的截图。
这是我为解决此问题所做的工作:
1- 我设置了 php 标头 iso-8859-9
2- 我将 apache 的默认字符集更改为 iso。
3- 我将 ajax 选项 beforeSend、setRequestHeader 和 contentType 设置为 iso。
4- 我修改了 jquery.js 并将 ajax 默认编码设置为 iso。
他们都没有解决我的问题。我不想做任何 php 字符集编码 btw。
还有其他想法吗?
谢谢
我的 ajax 代码: `
$.ajax({
url: window.location.href,
type: 'POST',
data: $(this).serialize(),
contentType: "application/x-www-form-urlencoded; charset=iso-8859-9",
success: function(result) {
$('#IcerikContent').html($(result).find("#Icerik"));
$('html, body').animate({scrollTop: 0}, 500);
Metronic.initAjax();
if (typeof initialize == 'function') { initialize(); }
stopPageLoading();
}
});
`
【问题讨论】:
标签: php jquery ajax apache utf-8