次のようなajaxリクエストを作成しています
var object = JSON.stringify(object);
// var url = "http://"+baseURL +"/"+endpoint;
$.ajax({
contentType: "application/json",
dataType: 'json',
type:type,
data:object,
url:endpoint,
success:function(data){
if (typeof callback == "function"){
alert(data);
}
},
error: function (xhr, textStatus, errorThrown) {
console.log(xhr.statusText);
console.log(xhr.responseText);
console.log(xhr.status);
console.log(errorThrown);
}
});
var=object
は、文字列化された json オブジェクトであり、ajax リクエストに組み込まれます。PHP側では、次のようにして変数をキャッチしようとしています
<?php
echo ($_POST['object']);
exit;
?>
私の成功コールバック関数は、データを「null」として警告します。私は何を間違っていますか?
ありがとう、アレックス