dongzhuan1185 2013-11-06 09:51
浏览 57

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

When i tried to get data from a UTF-8 encoded database with ajax in json-format and the data contains special characters like Ä,Ö,Ü,ä,ö,ü,... then the result set is empty!

$('.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');
        }
    });
});

Data records without german special characters will be successfully received and displayed.

  • 写回答

1条回答 默认 最新

  • douli4337 2013-11-06 09:55
    关注

    You should check the encoding of your browser, your server-side language, your database connection, your database, your table, your column. Make sure all of this is UTF-8.

    评论

报告相同问题?

悬赏问题

  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大