【发布时间】:2018-08-03 12:18:28
【问题描述】:
我在尝试从正文中包含土耳其语字符的 ajax 调用更新 Postgres 数据库 (UTF-8) 时发现了一个问题。 我有一个带有 id 和 name 属性的简单 json,名称包含“Kumar oyunları risk taşır” 并在数据库中保存“Kumar oyunlar�� risk ta����r”
$(document).ready(function () {
$("#sendToServer").click(function(){
var json = '{"name":"Kumar oyunları risk taşır", "id": 123'};
var server = "http://10.16.0.89:8080";
var apiURL = server + "/api/content/publish/create";
var dataform = new FormData();
dataform.append('json', JSON.stringify(json));
getURL = $.ajax({
url: apiURL,
type: 'PUT',
cache: false,
data: dataform,
contentType:false,
success: function (result, request, response, data, status, xhr) {
alert('Success!');
}
});
});
...
<button id="sendToServer">Send to server</button>
如果使用 json 代替 dataform 没有问题 (data: json) 但我真的需要它来使用它,因为我必须在我的应用程序中附加一个文件。
【问题讨论】:
-
没有服务器端代码我们只能猜测
-
一个细节我忘了说它在我的本地环境中运行良好,好吧,最后我认为问题是 Tomcat 编码,我刚刚按照stackoverflow.com/questions/11089783/… 上的解决方案,就是这样
标签: javascript ajax postgresql character-encoding turkish