Search code examples
javascriptjqueryutf8-decode

How can I decode UTF8 characters using jQuery?


I recently just solved the issue of outputting foreign characters using utf8_decode function in this thread: How do I convert, display and store this characters in PHP?

It works by directly echoing the results out but now I have this json_encode function to pass to jquery for the results. Json_encode is escaping my data to something like this:

{"title":"\u90ed\u5bcc\u57ce - \u641c\u7d22"}

How do I json_decode from jquery? Thank you for any advice.


Solution

  • Either you are writing it directly into JS, in which case do nothing or you are using one of ajax methods in jQuery, in which case just specify the dataType to be "json"