Dialog automatically closes when opened.
Hello,
I guess first I will tell you that as soon as I click the button that opens the dialog, it pops up for a second, submits a blank form to the db and then closes. Hopefully someone here can shed some light as to why it automatically closes on me before I get a chance to do anything. Here is some of the code. If you want more just let me know.
- $(document).ready(function() {
- $("#dialog").load('includes/ajaxInsert.php', function(response, status, xhr) {
- if (status == "error") {
- var msg = "Sorry but there was an error: ";
- $("#error").html(msg + xhr.status + " " + xhr.statusText);
- }
- }).dialog({
- modal: true,
- autoOpen: false,
- buttons: {
- Cancel: function() {
- $(this).dialog("close");
- }
- }
- });
- $(".submit").button().click(function () {
- $("#dialog").dialog("open");
- });
- });
and the HTML,
- <body>
- <div id="container">
- <div id="error"></div> <!-- error -->
- <select class="select1">
- <?php
- include ('getDropDown.php');
- ?>
- </select>
- <button class="submit">Add New</button>
- <div id="dialog"></div> <!-- dialog -->
- </div> <!-- container -->
- </body>