尝试将JavaScript数组传递给PHP时未定义的索引,网络日志显示连接成功但无法访问数组? [重复]

I'm trying to pass an array of latitude values into my PHP file so I can store them in a database. However nothing I've tried works. When trying to assign the sent array to a php array I get "undefined index".

The array of latitudes gets filled with values every 10 seconds once a button is pressed and stops when a stop button is pressed.

JavaScript

lat.push(position.coords.latitude); 

console.log(lat); // lat array definitely isnt empty

function stopJourney() // stops timer, called by button press
{
        clearInterval(timer);

        document.getElementById("journeyStart").disabled = false;

        $.ajax({
                type: 'POST',
                url: 'Functions.php',
                data: { 'latArray' : JSON.stringify(lat)},
                dataType: 'json'
        });

        window.location.replace("other page that isn't relevant");
}

my PHP

$_SESSION['latArray'] = json_decode($_POST['latArray']);

Gets this error

Notice: Undefined index: latArray in /.../.../.../.../PHP/Functions.php on line 293 // full file location not relevant

The lat array is accessible in the function

function stopJourney() // stops timer
            {
                clearInterval(timer);
                document.getElementById("journeyStart").disabled = false;

                var stringLat = JSON.stringify(lat);
                alert(stringLat);

                //$.ajax({
                //  type: 'POST',
                //  url: 'Functions.php',
                //  data: { 'latArray' : stringLat},
                //  dataType: 'json'
                //});

                //window.location.replace("other page that isn't relevant");
            }

Alert output is correct

var_dump($_POST)

Shows

array(1) {
  ["latArray"]=>
  string(20) "[53.732015499999996]"
}
</div>