i need to send a request to my controler, but ajax throwing and error. I can't seem to figure out why. Here is the code
HTTPS is before defined constant, which i cannot write here!
$("input").on("click", function(){
var elem = $(this).attr("id");
var execute;
if( $(elem).prop('checked') == true ){
execute = '+';
} else {
execute = '-';
}
$.ajax({
type:'POST',
url: HTTPS+'/path/to/controller/ctlAccess.php?do='+execute,
data: {id:elem},
success: function(data) {
console.log(data);
},
error: function(){
console.log("An error occurred: " + status + "nError: " + error); //AND ERROR: An error occurred: [object Object]nError: error
}
});
});
});
And here is the controller:
$SysData = new SysTables;
if ($_GET["do"] == "-") {
$userId = preg_match('/[0-9]*(?=p)/', $_POST['id']);
$pageId = preg_match('/(?<=p)[0-9]*/', $_POST['id']);
$result = $SysData->deleteAccess($userId, $pageId);
$data = "ACCESS FOR ". $_POST['id']." DELETED";
echo $data;
}
I think that requests do not even get to controler! I don't actually know hwere is the error. But path to file is right, and part where elem gets ir value works too, so i dont get where is the error!? Help please, thx