quasiman Posted May 17, 2013 Share Posted May 17, 2013 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 More sharing options...
quasiman Posted May 17, 2013 Author Share Posted May 17, 2013 Nevermind, I figured it out.... I set the dataType to 'json', but then I didn't properly set the object. Link to comment https://forums.phpfreaks.com/topic/278110-learning-jquery-ui-dialog-delete-record/#findComment-1430754 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.