Good day! I wonder why I cannot decode base64 response in javascript using atob or btoa or custom formulas like $.base64.decode().
This is what I have in php
$res = "Это тескт";
echo base64_decode($res);
This is what I have in jquery
$.ajax({
type: "GET",
url: "request.php",
success: function(data){
$('#elementid').html($.base64.decode(data));
//or $('#elementid').html(atob(data)); // it gives the same result as the above one.
On the page I see the following
ÐÑо ÑеÑкÑ
Base64 encoded data looks the following way
0K3RgtC+INGC0LXRgdC60YI=
If I try to decode using different web tools from BASE64 to UTF-8 I see correct result, but not on my page using the above functions. Please suggest.
UPDATE: @logic-unit thanks for the suggestion. I forgot to mention that the resulting page index.php has the following in the heading
<?php
header('Content-Type: text/html; charset=utf-8');
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
...
</head>