ajaxからphpにpostしたデータをphpで出力できません。 //jquery側 function (){ let alertInformation = {
ajaxからphpにpostしたデータをphpで出力できません。 //jquery側 function (){ let alertInformation = { "name": $("#sample1").val(), "eMail": $("#sample2").val(), "phone": $('#sample3').val() + "-" + $('#sample4').val() + "-" + $('#sample5').val(), "office": $("#sample6").val(), "info": $("#infomation").val(), "contents": $("#sample8").val(), "reply": $('input[name="email"]:checked').val(), "med": $('input[name="oppo"]:checked').map(function () { return $(this).val(); }).get() } $.ajax({ url: "../php/form.php", type: "POST", data: alertInformation, dataType: "json" }) .then(function () { alert("SUCCESS"); }) .catch(function (XMLHttpRequest, status, errorThrown) { console.log(XMLHttpRequest.responseText); console.log(status); console.log(errorThrown); alert("fail"); }) } //php側 $json = file_get_contents("php://input"); $data = json_decode($json); echo json_encode($data);
PHP | JavaScript・50閲覧