Hello I tried to transfer variable from ajax to php, but php file keeps throwing me the following:
Undefined index: vals in /Applications/XAMPP/xamppfiles/htdocs/fang_sophie/project/sign in-out/bin/readall2.php
Ajax reads like this:
<script>
var var_data = "Hello World";
$.ajax({ url: 'bin/readall2.php',
 data: {'vals' : var_data},
 type: 'post',
 dataType:'json',
 success: function(output) {
              alert(output);
          },
  error: function(request, status, error){
    alert("Error: Could not delete");
  }
});
</script>
Php reads like this:
<?php
  session_start();
  $hello = '';
  $_SESSION['hello'] = $_POST['vals'];
  echo($hello);
?>
Why doesn't it work? Please help :)
 
     
     
     
     
    