weixin_33738578 2013-06-28 02:06 采纳率: 0%
浏览 14

Ajax发送错误的字符集

Ajax is sending to PHP

Ĺ asija-kabina

Instead of

Šasija-kabina

While I did declare the charset everwhere. In the head of the html file I've got this:

<meta charset="ISO-8859-2">

In the PHP file I've got this:

header('Content-Type: text/html; charset=latin2');

And this is my ajax function where "str" is a json array:

function updateField(str, id, prevvalue, value, vehicletype){
    $.ajax({
        type: "get",
        url: "inc/ajax/form_rest.php",
        data: { q:str, prevvalue:prevvalue, value:value, vehicletype:vehicletype },
        contentType: "application/json;charset=latin2",
        success: function(html) {
                    $('#'+id).html(html);
                }
        })
        .done(function(){
            $("#"+id).removeAttr("disabled");
            if($("#"+id+" option").length == 2){
                $("#"+id).val($("#"+id+" option:last-child").val()).change();
            }
            if($("#"+id+" option:last-child").val() == ""){
                $("#"+id).attr("disabled", "disabled");
            }
        });
}

Nevertheless I am getting the wrong output. Can anyone help me with this?

  • 写回答

2条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 有偿找一份verilog语言的cnn代码带讲解
      • ¥15 关于#mysql#的问题:mysql 组内排名,取各组的销售金额前10
      • ¥15 有人用过颜色传感器吗?
      • ¥50 求一个SQL长料切短料的优化排版算法
      • ¥15 python 删除TXT文档中小写字母
      • ¥15 ValueError: not enough values to unpack (expected 2, got 0)
      • ¥15 js怎么禁止修改域名
      • ¥15 Cursor为什么在Windows11打不开
      • ¥30 java调用javacv遇到的问题
      • ¥15 如何使用matlab画出带宽100Khz,时长100ms信号的LFM形式的时频图啊