I have my JS code getting the values from piotnet form and making necessary calculations, after i populate the calculation and values from inputs to my object, then i launch Ajax The piotnet is front end form, which doesn't populate values in mysql.
$('BUTTON').on("click", function(){
/// for test reason i get only 2 values from form
var newsRev = {
ndatego: sReservation.dateGo,
ndateback: sReservation.dateBack
}
var json= JSON.parse(JSON.stringify(newsRev));
console.log(json);
jQuery.ajax({
type:'POST',
url:'https://mywebsite.com/test/', /// my elementor page with Code snippets shortcode
data: {json:json},
success: function(data) {console.log(data);}, /// getting as result
error: function(errorThrown){
console.log(errorThrown);
}
})
})
and in my shortcode, in page /test/ i have code
if($_SERVER['REQUEST_METHOD']=='POST'){
function (){
if(isset($_POST)){
$sre = $_POST['json'];
echo $sre;
print_r ($_POST); // showing nothing
}
die();
}
}
but its not working.. Thank you.....
I am new to php.... The target is to populate the calculations and input values in other wordpress page only for admin and also populate them in phpmyadmin database.
So i have worked it out, maybe will be useful for somebody.
and in my function.php in child theme: