Hi there
I'm trying to send from Ajax some variables to PHP Session variable.
Getting an error, but able to find what is wrong.
Here is my javascript:
...
<script>
function GetLine(el){
$.ajax({
url: 'put_session.php',
method: 'POST',
data:{
'toto': '0',
'tata': '0',
'titi': el.cells[0].innerHTML
},
success: function(response) {
console.log('Ok status: ' + response);
},
error: function(xhr, status, error){
var errorMessage = xhr.status + ': ' + xhr.statusText;
console.log('Error: ' + errorMessage );
}
});
window.location.href = 'newpage.php';
}
</script>
and here my php page to store session variable: (put_session.php)
<?php
session_start();
if (isset($_POST['toto'])) {
$_SESSION['toto'] = $_POST['toto'];
}
if (isset($_POST['tata'])) {
$_SESSION['tata'] = $_POST['tata'];
} if (isset($_POST['titi'])) {
$_SESSION['titi'] = $_POST['titi'];
}
echo "success";
?>
I get this error message: Error: 0: error
Thanks in advance for any help.
Ossy