user995719
user995719

Reputation: 47

Error when using `delete` as property name

I have a form that is deleting a gallery from a database. The code was working until a couple of weeks ago and I had other problems with it having to switch from jquery.interface to jquery-ui but now when I try to re-submit my changes to the svn I get an error. invalid property id. the line that throws the error is this:

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

Whole code snippet is:

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);
                }
            }
        );

Did some syntax change for $.post that I have not been aware of, I checked the docs and do not see anything that matches.

Upvotes: 1

Views: 86

Answers (1)

Kevin Bowersox
Kevin Bowersox

Reputation: 94469

Delete is a reserved word, so you must quote it.

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

Upvotes: 3

Related Questions