So, I'm using Jquery to make 4 lists to be sortable between themselves, and up to the visual part, it works great, I can even receive their data-attributes, but I can't seem to call the PHP function on the RECEIVE event of the sortable lists.
I've tried a few times to call it differently, using other methods, but nothing seems to work.
<?php
require_once '../../DAO/model.php';
$id = $_POST['id'];
$week = $_POST['week'];
$query = "UPDATE onboarding_checklist_week
SET week = '$week'
WHERE id = 'id'";
mysqli_query($conn, $query) or die (mysqli_error($query));
?>
DAO/MODEL is my connection with SQL, it works just fine for the entire project, but as far as I can see, it's not even calling the PHP function, so it's not some connection problem.
$(document).ready(function() {
$('#1').sortable({
cancel: ".collapsible-header",
connectWith: '#2, #3, #4, #5',
receive: function (event,ui) {
var id = ui.item.attr('data-identifier');
var week = '1';
$.ajax({
url: 'changeEvents.ajax.php',
type: 'POST',
data: {
'idTask' : id,
'week': week
}
});
}
});
$('#2').sortable({
cancel: ".collapsible-header",
connectWith: '#1, #3, #4, #5',
receive: function (event,ui) {
var id = ui.item.attr('data-identifier');
var week = '2';
$.ajax({
url: "changeEvents.ajax.php",
type: "POST",
data: {
'idTask' : id,
'week': week
}
});
console.log('funcionou');
}
});
It repeats three more times, one for each table.
It should be working, but it's not, doesn't matter how many times I move the elements around, it won't call my php function.
if I use console.log('id'), for example, I seem to be receiving the id of the elements just fine.