使用`delete`作为属性名时出错

时间:2013-04-24 00:14:00

标签: javascript jquery ajax

我有一个从数据库中删除图库的表单。代码工作到几个星期前我还有其他问题,它必须从jquery.interface切换到jquery-ui但现在当我尝试将我的更改重新提交到svn时,我得到一个错误。无效的属性ID。抛出错误的行是:

post:$("#post").val(), delete:true

整个代码段是:

var answer = confirm("This will permanently delete this entire gallery. Are you sure you want to proceed?");
    if (answer) {
        $.post(
            "admin-ajax.php?action=gallery_submit",
            { post:$("#post").val(), delete:true },
            function(data){
                if (data == 1) { //success
                    $('body').html('<div class="success">Your gallery has been successfully deleted.</div>');
                    setTimeout(function() { tinyMCEPopup.close(); }, 2000);
                } else { //error
                    alert('There was an error with deleting your gallery, and so, it was NOT deleted.\n\r\n\rThe following error was encountered:\r\n' + data);
                }
            }
        );

我没有注意到$ .post的一些语法更改,我检查了文档并且没有看到任何匹配的内容。

1 个答案:

答案 0 :(得分:3)

删除是一个保留字,因此您必须引用它。

 { post:$("#post").val(), "delete":true },