Problem with respinse function after edit a record

Problem with respinse function after edit a record

isaireyes29isaireyes29 Posts: 1Questions: 1Answers: 0

I have a problem after to edit a record. The below code is thw way that I using Edit function.
I need the success function to update a counting panel, the problem is that I can update the record but the modal pop can´t close, and If I close manually, I can´t edit another record after that.

JS

editor = new $.fn.dataTable.Editor({
                "table": "#example",
                "idSrc": "id",
                "fields": [{
                        label: "Estado:",
                        name: "estado",
                        type: "select",
                        options: [
                            {label: "Nuevo", value: "4"},
                            {label: "En progreso", value: "5"},
                            {label: "Con venta", value: "6"},
                            {label: "Sin venta", value: "7"},
                        ]
                    }],
                ajax: function (method, url, data, success, error) {
                    if (data.action === 'edit') {
                        $.ajax({
                            type: 'POST',
                            url: 'controller/updateJson.php',
                            data: {
                                data: JSON.stringify(data)
                            },
                            success: function (jsonLog) {
                                var data = jsonLog;
                                var objects = JSON.parse(data);
                                document.getElementById("tTotal").innerHTML = objects.tTotal;
                                document.getElementById("tNuevo").innerHTML = objects.tNew;
                                document.getElementById("tProgress").innerHTML = objects.tProgress;
                                document.getElementById("tVenta").innerHTML = objects.tSold;
                                document.getElementById("tNoVenta").innerHTML = objects.tNoSold;
                            },
                        });
                    }
                }
            });

PHP

$response = array(
        "data" => $data,
        "tTotal" => $totalCustomer,
        "tNew" => $newCustomer,
        "tProgress" => $progressCustomer,
        "tSold" => $soldCustomer,
        "tNoSold" => $noSoldCustomer,
    );
    echo json_encode($response);

Answers

  • colincolin Posts: 15,146Questions: 1Answers: 2,586

    Hi @isaireyes29 ,

    The final example on this page should help. You need to call success() with the json so that Editor knows it's completed.

    Cheers,

    Colin

This discussion has been closed.