js ページで ajax リクエストを使用して json オブジェクトを渡したいのですが、それを行うと、php で $_POST 配列が空になります。
JavaScript ページ
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);
});
}
これは私のphpページです
<?php
header('Content-Type: application/json',true);
header('Accept: application/json');
$tipo = $_POST['type'];
$ris = json_decode($tipo,true);
var_dump($ris);
?>
助言がありますか?