A
A
Anatoly Smilik2018-04-03 20:30:29
PHP
Anatoly Smilik, 2018-04-03 20:30:29

Why doesn't JQuery send data to $_POST when sending a POST request to a url containing Cyrillic escape?

Hello.
I have a problem and I can't find a solution. Please help. Essence of the question. Sending data from the browser to the server:

// c подобным урл $_POST на сервере заполняется данными из $data
var $url = '/category/tag/qweqwe-21321';
// с подобным url $_POST на сервере не заполняется данными из $data, в нем кириллица кодирована encodeURIComponent
$url = '/category/tag/%D0%91%D0%B8%D0%BE%D0%BB%D0%BE%D0%B3%D0%B8%D1%8F';
var $data = {'left_menu_filter': $left_menu_filter, 'ajax-action': 'find-programm'};
$.post({
    url: $url,
    data: $data,
    success: actionAfterSendLeftMenuFormData,
    dataType: 'json'
});


The problem is that when we send a request to a url containing encoded Cyrillic characters, then on the server php does not fill in the $_POST array. And also, in this case, the $_SERVER array contains the following values:
[REQUEST_METHOD] => GET
[REQUEST_URI] => /category/tag/%D0%91%D0%B8%D0%BE%D0%BB%D0%BE %D0%B3%D0%B8%D1%8F
That is, on the server side, the request is perceived as a GET, not a POST.
In the browser, the debugger shows the following values:
Request Method: POST
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Form Data (POST data), example:
left_menu_filter[categoryId]: 50
left_menu_filter[specialization][]: 371
left_menu_filter[price_from]: 2390
left_menu_filter[price_to]: 21900
ajax-action: find-programm


Can you tell me where is the error?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anatoly Smilik, 2018-04-03
@sagechild

In general, the problem turned out to be in the mod_rewrite rules of the Apache web server. Since, when the request was in Cyrillic, not a single rule worked and redirected to 404.

F
frees2, 2018-04-03
@frees2

This one is not a quiri, it can be passed without escape via fetch
Request, fetch and : focus, what else can be screwed?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question