gpt4 book ai didi

php - 当数据库中存在特殊字符时,Ajax不返回结果集

转载 作者:行者123 更新时间:2023-11-29 08:19:32 26 4
gpt4 key购买 nike

当我尝试使用 json 格式的 ajax 从 UTF-8 编码的数据库获取数据并且数据包含特殊字符(如 Ä,Ö,Ü,ä,ö,ü,... 时,结果集为空!

$('.club-details').click(function() {
var element = $(this);
var data = {
gid: $(this).parent().parent().parent().parent().data('gid'),
club_number: $(this).parent().parent().data('club')
};
$.ajax({
type: 'POST',
url: TRANSFER_CALLS_URI,
data: 'key=getClubDetails&data=' + JSON.stringify(data),
dataType: 'json',
success: function(response) {
var html = "";
html += "<table>";
html += " <tr>";
html += " <td>Name kurz</td>";
html += " <td>" + response[0].name_short + "</td>";
html += " </tr>";
html += " <tr>";
html += " <td>Schießstätte</td>";
html += " <td>" + response[0].location + "</td>";
html += " </tr>";
html += " <tr>";
html += " <td>Telefon</td>";
html += " <td>" + response[0].phone + "</td>";
html += " </tr>";
html += "</table>";
element.unbind('click').popover({
content: html,
title: 'Vereinsinformation',
html: true,
placement: 'bottom'
}).popover('show');
},
error: function() {
$.error('Ajax');
}
});
});

不含德语特殊字符的数据记录将成功接收并显示。

最佳答案

您应该检查浏览器的编码、服务器端语言、数据库连接、数据库、表、列。确保所有这些都是 UTF-8。

关于php - 当数据库中存在特殊字符时,Ajax不返回结果集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19808774/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com