(06-21-2022, 06:48 PM)spreaderman Wrote: (06-21-2022, 11:34 AM)maulahaz Wrote: Did you try :
Code:
if($id == ""){
$response = [
'success' => 0,
'msg' => "No Task To Delete",
];
echo json_encode($response);
} else {
$task = new TaskModel();
$task->task_delete($id);
$response = [
'success' => 1,
'msg' => "Task Deleted",
];
echo json_encode($response);
}
So the problem is I cannot get see any $_POST head info and also cannot see $id in headers. It isn't a logic error, I think. I tried about but as $id is blank it is always "No task to delete".
In your Ajax call your dataType is 'json'. However the CONTENT_TYPE may not be correct in the header. Try replacing $request->getVar('id') with $request->getJsonVar('id')