Suppose there is the javascript with ajax request -
index.js-
var dataFeedback = $("#feedback_popup_message_body").val();
var jsonObj = JSON.stringify({dataFeedback: dataFeedback});
$.ajax({
url: "index.php",
type: 'POST',
data: jsonObj,
dataType: 'json',
success: function (data) {
console.log(data);
}
});
and in the server side , php page -
index.php-
<?php
$myPostData = json_decode($_POST["dataFeedback"]);
$feedback = $myPostData["dataFeedback"];
echo $feedback;
?>
I try to send with the request a json object and once it parsed in the server side, get it back to the client page and logs its data .
In the above concept it doesn't logs the data value .
I checked it in Chrome > F12 > Networks > index.php > Response and found this -
<br />
<b>Notice</b>: Undefined index: dataFeedback in <b>...\index.php</b> on line <b>11</b><br />
How to cause it to logs the data which backs from the server ?
Update: The code that finally cause it works -
index.js-
var dataFeedback = $("#feedback_popup_message_body").val();
$.ajax({
url: "bin/bll/suggestionSummary.php",
type: 'POST',
data: {dataFeedback: dataFeedback},
success: function (data) {
console.log(data);
}
});
index.php-
<?php
$myPostData = $_POST['dataFeedback'];
echo $myPostData;