I have a phtml file. In file i have written some html in which there are some inputs and a button. In javascript i am validating the inputs and then posting using jquery like that
url = document.URL;
$.post(url, { name: "John", time: "2pm" } );
Then in the same page i have written some php to get the data like that,
<?php
if(isset($_POST['name'])) {
$name = $_POST["name"];
$time = $_POST["time"];
}
?>
Am i doing right?