i want to pass a json object with ajax request in my js page but when i do it, in php i have the $_POST array empty.
javascript page
function invia(cat,subcat)
{
var tipo = cat.options[cat.selectedIndex].text;
var sottotipo = subcat.options[subcat.selectedIndex].text;
var lat = getLatitudine();
var lon = getLongitudine();
$.ajax({
type:'POST',
url: "apriSegnalazione.php",
dataType: "json",
data : {
type: {type: tipo, subtype: sottotipo};
lat: lat,
lng: lon
}
}).success(function(data){
alert( "Data Saved: "+ data);
});
}
and this is my php page
<?php
header('Content-Type: application/json',true);
header('Accept: application/json');
$tipo = $_POST['type'];
$ris = json_decode($tipo,true);
var_dump($ris);
?>
any suggestions?