accent ajax encoding issue

后端 未结 2 873
遥遥无期
遥遥无期 2021-01-22 06:12

Source file has:

header(\'Content-type: text/html; charset=iso8859-1\');

Source ajax (jQuery) script is:

$(document).ready         


        
相关标签:
2条回答
  • 2021-01-22 06:23

    This is because you are displaying UTF-8 encoding of é (0xc3, 0xa9) as Latin-1. So the search_word was encoded as UTF-8 when it posted to PHP.

    Try this,

    $.ajaxSetup({
            scriptCharset: "iso-8859-1",
            cache: false
    });
    
    0 讨论(0)
  • 2021-01-22 06:30

    That is because the default return type of an AJAX call is UTF-8. Try

    utf8_encode($output);
    

    in your ajax snippet. Alternatively, you can change the encoding of the AJAX request as described here.

    0 讨论(0)
提交回复
热议问题