Code: I have 2 variables
<script type="text/javascript" src="code.jquery.com/jquery-3.2.1.min.js"></script>
<script>
var var1 = $("#var1").val(); var var2 = $("#var2").val();
$.ajax({
url:'recibo.php',
data:{var1:var1,var2:var2},
type:'POST',
datatype:'json'
})
</script>
My intention is to send them by the url HIDDEN OR ENCRYPTED or if there is another way to send them either by JQUERY OR AJAX
My intention is to send the values to another page with the following code .. Page Example.php
<?php
$var1=1;
$var2=2;
echo "<div class='inner arriba' id='for'>
<a href='#'><input type='text' name='var1' id='var1' value='$var1'> <input type='text' name='var2' id='var2' value='$var2'></a>
</div>";
?>
<html>
<head>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script>
var var1 = $("#var1").val();
var var2 = $("#var2").val();
$.ajax({
url:'recibo.php',
data:{var1:var1,var2:var2},
type:'POST',
datatype:'json'
})
var jqxhr = $.ajax( "recibo.php" )
.done(function() {
alert("Succes");
})
.fail(function() {
alert( "error" );
})
.always(function() {
alert( "complete" );
});
jqxhr.always(function() {
alert( "second complete" );
});
</script>
</head>
<body>
</body>
</html>
Page emjemplo2.php
Here I want to receive the sent values, I am investigating how to receive it with json since the shipping method I use is datatype: 'json'
<?php
echo $resultado = $_POST['var1'] + $_POST['var2'];
echo $ca=$_POST['var1'];
echo $ca2=$_POST['var2'];
?>