douyi3833 2019-07-31 16:48
浏览 75

JQUERY sortable不会调用php函数

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 划分vlan后不通了
    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 Revit2020下载问题
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大