Firstly I would like to describe what's wrong.
This is my Jquery code and it's good.
$.ajax({ url: 'ajaxHandler.php',
data: {'list' : 'list'},
type: 'post',
dataType:'json',
success: function(output) {
alert(output);
},
error: function(request, status, error){
alert("Error: Could not delete");
}
});
But problem is it i have just wanted to create the same in vanilla js.
var request = new XMLHttpRequest();
request.open("POST", url, true);
//Send the proper header information along with the request
request.setRequestHeader("Content-type", 'application/json; charset=UTF-8');
request.onreadystatechange = function() {
if (request.readyState == 4 && request.status == 200) {
alert(request.responseText);
};
}
var dataParam = {
'list': 'list'
};
var $json = JSON.stringify(dataParam);
request.send($json);
Is Anybody who could tell me where is my mistake.
<?php
require_once 'tasksController.php';
$dataFunction = (string)($_POST['list']);
echo $dataFunction;
?>
This is my alert : Notice: Undefined index: list in C:\xampp..........\ajaxHandler.php on line 3