当我尝试使用 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');
}
});
});
没有德语特殊字符的数据记录将被成功接收和显示。