Accent x JSON(Jquery)

Asked

Viewed 300 times

-1

How should I proceed in Jquery so that the return request via json is / is with the correct accent? Current: "Monday, 12 de Março de 2018" Precise: "Monday, March 12, 2018"

I’m trying to use that:

$.ajax({
        async:false,
        type: "GET",
        url: "portal.local/servico/datas/",
        dataType: "text",
        contentType: "application/x-www-form-urlencoded;charset=ISO-8859-1",
        success: function (data) {
           alert(data);
        }
    });
  • and with dataType: 'json', what happens?

  • You’re calling this file js on some page html, right? If yes, put this on your tag script <script src="example.js" charset="utf-8"> </script>

  • dataType:"json" result is Monday 12 Mar&amp;ccedil;o 2018.

  • @Diegoalbuquerque already tried to do what I suggested?

  • I put charset="utf-8" in the script and tbm was not =/

  • You have control of the code that generates this JSON?

Show 1 more comment

1 answer

0

If it is a php page it returns json seven your head.

header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
echo json_encode(<strong>"meu array", JSON_UNESCAPED_UNICODE);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.