I tried everything but it still don't work. Without $_POST value it is working, without JSON it's working, with both it's not. Function shows this error:
<b>Notice</b>:  Undefined index: someVar1 in <b>C:\xampp\htdocs\ajax3\test.php</b> on line <b>2</b><br />
Array()
{"jeden":"Po obr\u00f3bce  123  123 ","dwa":null}"
script.js
$(document).ready(function(){
    var data = {
        someVar1: '123'
    };
    data = JSON.stringify(data);
    $.ajax({
        method: "POST",
        url: "test.php",
        dataType : 'json',
        contentType: "application/json; charset=utf-8",
        data: data,
        success: function(json) {
            $.each(json, function(i, ob) {
                console.log(i, ob);
            });
        },
        error: function(error) {
            console.log(error);
        }
    });
});
and test.php
<?php
    $someVar1 = $_POST['someVar1'];
    $a = " 123 ";
    $result = array();
    $result['jeden'] = 'Po obróbce ' . $a . $a;
    $result['dwa'] = $someVar1;
    echo json_encode($result);
?>
 
    