json with special characters like é

前端 未结 3 1491
迷失自我
迷失自我 2020-12-10 01:34

I\'m developing a dependent select script using jQuery, PHP and JSON as the response.

Everything goes well except for using special characters like French ones (é ,

3条回答
  •  春和景丽
    2020-12-10 02:22

    If I write them like (é) and don't pre-encode them the full value in this array entry is not shown.

    What should I do here?

    In JSON you do not HTML-encode values. You send them literally (é) and set set Content-Type correctly:

    header('Content-Type: application/json; Charset=UTF-8');
    

    Declare the encoding your data is in, of course.

提交回复
热议问题