'jQuery UI dialog reloads the page when you click on close button. What is wrong?

In my dialog have two buttons. If I click on the close button the dialog box closes and page reloaded. How to close dialog without page reloading? My code:

add_bankday.dialog({
            autoOpen: false,
            width: 400,
            buttons: [{
                id: 'submit',
                text: <?php echo json_encode('Add'); ?>,
                click: function(event){

                    if ($('#password').val() != calendar.resource.password){
                        $('#error').text(<?php echo json_encode('Wrong password'); ?>).css('visibility', 'visible');
                        return;
                    }

                    $.ajax({
                        type: 'POST',
                        url: 'ajax.php',
                        async: false,
                        data: {
                            op: 'add_bankday',
                            day: $('#new_bank_day').val(),
                            password: $('#ab_password').val()
                        },
                        success: function(res){
                        }
                    });
                }
            },
            {
                id: 'bank_close',
                text: <?php echo json_encode('Close'); ?>,
                click: function(){
                    $('#new_bank_day').val('');
                    $('#add_bankday').dialog('close');
                }
            }]
        });


Solution 1:[1]

Just an idea: Since it look like you're using ajax requests make sure you have disabled any normal html form submission controls and use plain html buttons!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Stephen Tierney