Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


Question:Json Ajax PHP is NULL


I get an array with the geolocation Javascript, then I want to pass this array to a php script via ajax to process it and get an processed array back. Unfortunately it seems that the passed array to php is always NULL, I have no idea why, maybe you can help me out. Thank you!

my js/jquery:

dataArray = [];
        var lat = pos.coords.latitude;
        dataArray.push({'lat':lat});
        var lon = pos.coords.longitude;
        dataArray.push({'lon':lon});
        var identifier = 'ajax';
        dataArray.push({'identifier':identifier});
        console.debug(dataArray);

        $.ajax({
                async:   true,
                type:        'post',
                cache:       false,
                url:         'custom.php',
                data:        {myJson: dataArray},
                dataType   : 'json',
                success: function(data){
                    console.debug(data);
                    var json = $.parseJSON(data);
                    console.debug(json);
                    alert(json);
                }
        });

my php:

$JSArray['array'] = json_decode($_POST['myJson'], true);
$_SESSION['jsonArray'] = $JSArray['array'];
var_dump($_SESSION);

The Result is always ["jsonArray"]=> NULL

asked Sep 13, 2013 in jquery by anonymous
edited Sep 12, 2013
0 votes
26 views



Related Hot Questions



Walkin Jobs Opening



Government Jobs Opening


...