Jump to content

learning jquery ui - dialog delete record


Go to solution Solved by quasiman,

Recommended Posts

Hi, I'm trying to learn jquery ui (without much of a javascript background), and I think I'm pretty close to what I want.....but the error I'm seeing doesn't make much sense to me.  Here's my code first:

        <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
        <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
        <script>
            $(function() {
                var contactid = "<?php echo $_GET['contactid']; ?>";
                $( "#dialog-confirm" ).dialog({
                    autoOpen: false,
                    resizable: false,
                    height:290,
                    width:450,
                    modal: true,
                    buttons: {
                        "Delete": function() {
                            $.ajax({
                                type: "POST",
                                url: 'delete-contact.php',
                                data: {contactid:  contactid},
                                dataType: 'json',
                                context: $(this),
                                cache: false,
                                statusCode: {
                                    404: function() {
                                        alert("page not found");
                                    },
                                    200: function() {
                                        alert("200 success");
                                    }
                                }
                            }).then(
                            function(){ alert("$.ajax succeeded"); },
                            function(){ alert("$.ajax failed!"); }
                        );
                        },
                        Cancel: function() {
                            $( this ).dialog( "close" );
                        }
                    }
                });
                $( "#confirm-delete" )
                .button()
                .click(function() {
                    $( "#dialog-confirm" ).dialog( "open" );
                });
            });
        </script>

Now, you can see I have a few alerts in there, and I'm getting two to popup, first '$.ajax failed!', followed by '200 success'.  I check Firebug and I can see the post successful (to a dummy file just echoing the $_POST), so I don't understand why I'm seeing the deferred.then() return an error.

 

Any ideas for jquery newbie?   :)

Link to comment
https://forums.phpfreaks.com/topic/278110-learning-jquery-ui-dialog-delete-record/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.