如何删除数据库使用数组方法DELETE

how to remove DB using Arry String method DELETE?

本文关键字:数组 方法 DELETE 数据库 何删除 删除      更新时间:2023-09-26

我试图删除数据从我的数据库使用下面的ext.js脚本:当我点击"删除"图标时,它似乎在浏览器上工作,但当我点击其他工具栏时,在浏览器上点击一些。它被重新加载了我在行网格上的相同数据。我真的不知道我只删除数组,而不是通过发送错误的服务器或方法删除实际的DB。我不知道。我尝试使用不同的方法来删除它,但它同样的问题回来了。

有人能帮我吗?我是ext.javascript或ext.Ajax等的新手。

代码:

var userHistoryGrid = Ext.create('Ext.grid.Panel', {
    width: 880,
    height: 450, //autoHeight: true, collapsible: false, title: 'Employee''s Request History', icon: 'images/newtodo1.png', store: userHistoryStore, multiSelect: false, columnLines: false, enableColumnHide: false, enableColumnMove: false, enableColumnResize: false, selType: 'rowmodel',
    viewConfig: {
        emptyText: 'No prior requests',
        stripeRows: false,
        enableTextSelection: true,
        getRowClass: function (record) {
            return record.get('Status') == 'Approved' ? 'normal-row' : 'hilite-row';
        }
    },
    items: [{
        icon: 'images/delete.png',
        tooltip: 'Delete Request',
        handler: function (grid, rowIndex, colIndex) {
            record = grid.getStore().getAt(rowIndex);
            cellvalue = record.get('Delete');
            if (cellvalue != 'Delete') {
                Ext.MessageBox.confirm(
                    'Confirm Deletion',
                    'Delete this request?',
                function (btn) {
                    if (btn == 'yes') {
                        cellvalue = record.get('EventID');
                        Ext.Ajax.request({
                            url: 'delUserHistoryGrid.asp',
                            async: false,
                            method: 'DELETE',
                            params: {
                                id: userHistoryStore
                            },
                            timeout: 30000,
                            success: function (result) {
                                userHistoryStore.reload();
                                userinfoStore.reload();
                            }
                        });
                        //delete userHistoryStore[rowIndex];
                        userHistoryStore.removeAt(rowIndex);
                        //eventStore.destroy(rowIndex);
                        //userHistoryStore.destroy(rowIndex);
                        //record.EventID.removeAt(grid);
                        userinfoStore.reload();
                    } else {
                        rowEditing.cancelEdit();
                    }
                });
            }
        }
    },

帮助您确定问题的提示:

  1. 在ajax调用后不要从存储中删除记录。只有成功了才去做。将userHistoryStore.removeAt(rowIndex);移动到success回调中。我不认为async: false真的存在。因此ajax调用立即返回。您应该在回调中继续执行流程。

  2. 添加failure回调并检查(断点或日志)您得到的响应。您还应该检查success情况中的响应,因为那里也可能有一些感兴趣的消息。

  3. 使用浏览器开发工具检查网络。您应该首先验证ajax调用是否成功执行,然后验证是否收到有效的应答。检查响应代码。如果不是在2005年,那就是一个错误。当你看到你得到的响应代码时,你可以在网上搜索更多。

  4. 在不了解您的服务或应用程序的情况下,我认为将整个商店作为您的id参数传递可能是错误的。你不应该通过cellvalue吗?