]> git.nbdom.net Git - nb.git/commitdiff
Fix delete
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Sat, 13 May 2023 14:12:05 +0000 (15:12 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Sat, 13 May 2023 14:12:05 +0000 (15:12 +0100)
lib/js/nb.js
lib/php/db/table.php

index 73fb8cdb815569ea9aa1fd8eb8a9c3ebff7f712d..e2db5637521889e6dee8479454634d78a2a411c8 100644 (file)
@@ -640,11 +640,15 @@ jQuery.fn.href2delete = function(minus_one,minus_one_re) {
                        // NB 13.05.23 $(this).parent().parent().remove();
                        $.ajax({
                                url: href,
-                               type: 'DELETE',
+                               type: 'GET',
                                success: function(result) {
                                        if (minus_one) $(minus_one).numAdd(-1,minus_one_re);
                                        $(this).parent().parent().remove();
                                        $(this).removeClass('loading');
+                               },
+                               error: function (xhr, status, error) {
+                                       $(this).removeClass('loading');
+                                 alert(status+' '+xhr.status+' '+error);
                                }
                        });
                });
index e0673e49bc3512d49a41a51775b9d64d1d814b21..1468c356e1e8c806d9e6444ad9098ffb341e2168 100644 (file)
@@ -2032,7 +2032,13 @@ Class Table extends nb {
                        return $this->out($this->info());
 
                } elseif ($action == 'table.delete') {
-                       if (!$this->delete($_POST,$e) and !isset($e['rowCount'])) bye($e);
+                       # NB 13.05.23: Query could be GET from js  
+                       $params = ($_SERVER['REQUEST_METHOD'] == 'GET')
+                               ? $_GET
+                               : $_POST
+                       ;
+                       #debug($params);
+                       if (!$this->delete($params,$e) and !isset($e['rowCount'])) bye($e);
                        $this->db()->print_header('Location',$this->url_referer(str_replace('&amp;','&',$this->url_list())));
                        $this->out($e);
                        return true;