Answer the question
In order to leave comments, you need to log in
Why does an Ajax GET request containing Cyrillic characters return crocodile characters?
It returns crocozyabras to me кухни, after php function rawurlencode %D0%BA%D1%83%D1%85%D0%BD%D0%B8. The utf8 encoding without the boom in htacces by default is also written on the page. Is it possible to somehow convert it back to Cyrillic? The data is taken from the input using the jquery method, here is the code:
<div><input id="p_38" class="checkbox pourpo" type="radio" name="parameters" value="Для ванной"><label for="p_38">Для ванной</label></div>
$('.pourpo').click(function(){
var template = $("#usageList").html();
var inppourpo = $(this).val();
$.ajax({
type: 'get',
url: '/filter/pourpose/'+inppourpo,
dataType: 'json',
contentType: 'application/json',
success: function(data) {
$(".prodlist").html(_.template(template,{inppourpo:inppourpo }));
}
});
});
Answer the question
In order to leave comments, you need to log in
This often happens when the web server (apache, nginx, etc) does not specify an encoding
Try to form the url parameter like this:
And on the server side, to get the original string, use urldecode ().
By the way, the parameter contentType
tells the server what data was passed to it by the ajax request. In this case, no data in the parameter data
is transmitted to the server, I don’t see the point of specifying contentType ( details ).
Your kryakozyabry is an attempt to read UTF-8 as WINDOWS-1251. Are you sure the display encoding is UTF-8?
Just because an encoding is set in .htaccess doesn't mean it can't be overridden elsewhere. Look in the browser debugger and check for the necessary headers, or try hard-coding the data encoding before uploading.header("Content-Type: text/html; charset=utf-8");
Or the required encoding is not specified in the ajax request, or when displayed in meta tags. Once upon a time, I suffered for a long time.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question