dialog with click and ajax call

dialog with click and ajax call

This is an odd one. I have a dialog and when I click the Save button it submits an ajax call. This works fine - in the code below showing an error because the page does not exist.

However hitting the return key does not work with the jquery dialog so I have created an event to capture the return key and then call "click()" on the Save button. This correctly calls the Save function for my dialog and runs showing the clicked and complete alerts without any errors being reported. It seems to ignore the ajax request.

        $('#form1').dialog({
            autoOpen: false,
            modal: false,
            width: 'auto',
            buttons: {
                'Save': function(){
                    alert("clicked")
            $.ajax({
          url:"addfkjhkjield.json",
success: function(){alert("success")},
error: function(){alert("error")}
})
    alert("complete")
                 },
                'Cancel': function(){
                    $('#form1').dialog('close')
                }
            }
        });