What I'm looking is that when the button is clicked then the values are taken and put into variables. The variables are then used in the AJAX call, so I can post them.
function addTask(){
$("#add_task_button").click(function(){
var task_title = $('#add_task_title').val();
var task_description = $('#add_task_desc').val();
var task_member = $( "#task_member option:selected" ).text();
var task_status = $( "#task_status option:selected" ).text();
$.ajax({
url: '../php_scripts/add_task.php',
type: 'POST',
data: {'title': task_title, 'description': task_description, 'member': task_member, 'status': task_status},
success: function() {
alert("SUCCESS");
},
error: function(jqXHR,textStatus,errorThrown) {
alert("FAILURE");
}
});
});
}
This is the jQuery and AJAX call
<?php
require_once "cdbconnect.php";
$taskTitle = $_POST['title'];
$taskDescription = $_POST['description'];
$memberName = $_POST['member'];
$groupName = "test";
$status = $_POST['status'];
$query = "INSERT INTO task_tbl (Task_title, Task_description, Member_Name, Group_Name, Status) values('$taskTitle', '$taskDescription', '$memberName', '$groupName', '$status')";
$result = $conn -> query($query);
if(!$result)
{
$conn -> error;
}
mysqli_close($conn);
?>
This Is the PHP file. I always receive the failure alert as the data is not submitted to the table.
Am I missing something here?