Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6108699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:19:25+00:00 2026-05-23T14:19:25+00:00

I’m using jQueryUI’s dialog with the modal form option to open a popup form.

  • 0

I’m using jQueryUI’s dialog with the modal form option to open a popup form. When the user clicks a button, it submits their input to a database, and then should close the dialog. Everything is working EXCEPT the closing of the dialog. (The manual Close button works; it just doesn’t automatically close after coming back from the PHP database script. Here’s the script code. (I tried to bold the line that’s not working; apparently you can’t nest bold inside of code tags, but the line is surrounded with double asterisks to make it stand out. Those are not part of the actual code!)

<script>
    $(function() {
        // a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
        $( "#dialog:ui-dialog" ).dialog( "destroy" );

        var name = $( "#name" ),
            email = $( "#email" ),
            company = $( "#company" ),
            plate = $( "#plate"),
            allFields = $( [] ).add( name ).add( email ).add( company ).add( plate ),
            tips = $( ".validateTips" );

        function updateTips( t ) {
            tips
                .text( t )
                .addClass( "ui-state-highlight" );
            setTimeout(function() {
                tips.removeClass( "ui-state-highlight", 1500 );
            }, 500 );
        }

        function checkLength( o, n, min, max ) {
            if ( o.val().length > max || o.val().length < min ) {
                o.addClass( "ui-state-error" );
                updateTips( "Length of " + n + " must be between " +
                    min + " and " + max + "." );
                return false;
            } else {
                return true;
            }
        }

        function checkRegexp( o, regexp, n ) {
            if ( !( regexp.test( o.val() ) ) ) {
                o.addClass( "ui-state-error" );
                updateTips( n );
                return false;
            } else {
                return true;
            }
        }

        $( "#dialog-form" ).dialog({
            autoOpen: false,
            height: 390,
            width: 350,
            position: 'top',
            modal: true,
            zIndex: 3000,
            buttons: {
                "Submit your plate": function() {
                    var bValid = true;
                    allFields.removeClass( "ui-state-error" );

                    bValid = bValid && checkLength( plate, "plate code", 1, 7 );
                    bValid = bValid && checkLength( email, "email", 6, 80 );
                    bValid = bValid && checkLength( company, "company", 1, 100);

                    bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "eg. ismi@instoremarketer.org" );


                    if ( bValid ) {

                            var nameStr = name.val();
                            var emailStr = email.val();
                            var companyStr = company.val();
                            var plateStr = plate.val();

                            var string = 'name='+ nameStr+'&email='+emailStr+'&company='+companyStr+'&plate='+plateStr;
                            //alert('string: '+string);


                            $.ajax({
                               type: "POST",
                               url: "submit_plate.php",
                               data: string,
                               dataType: 'json',
                               cache: false,
                               success: function(returnData){
                                                            alert(returnData.msg);
                                if(returnData.error === false) {
                                    **$( this ).dialog( "close" );**
                                }
                                else {
                                    alert("Error: "+returnData.msg);
                                }
                              }

                             });


                    }
                },
                Cancel: function() {
                    $( this ).dialog( "close" );
                }
            },
            close: function() {
                allFields.val( "" ).removeClass( "ui-state-error" );
            }
        });

        $( "#submit-plate" )
            //.button()
            .click(function() {
                $( "#dialog-form" ).dialog( "open" );
            });
    });
</script>

Any ideas?
EDITED TO ADD PHP CODE

<?php
include('../cfg/ez_sql.php');
include('../cfg/db_setup.php');

$err = false;
if (isset($_REQUEST['plate'])) {

    $raw = "INSERT INTO dot_plate_submissions (plate_code, plate_name, plate_company, plate_email) VALUES ('%s', '%s', '%s', '%s')";
    $clean = sprintf($raw,
               mysql_real_escape_string($_REQUEST['plate']),
               mysql_real_escape_string($_REQUEST['name']),
               mysql_real_escape_string($_REQUEST['company']),
               mysql_real_escape_string($_REQUEST['email']));

    //error_log("cleaned query: $clean");

   $db->query($clean);
}
else {
    $err = true;
}

if($err) {
    $return['error'] = true;
    $return['msg'] = "There was an error submitting your plate";
}
else {
    $return['error'] = false;
    $return['msg'] = "made it to php";
}
echo json_encode($return);
?>

So even if the error is false, the ajax call should still get back two pieces of data.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:19:25+00:00Added an answer on May 23, 2026 at 2:19 pm

    I got this solved months ago but forgot to come back here and post the solution. It had nothing to do with my code; it was just a version conflict between jqueryui and jquery. I was using an older version of jquery; once I updated my library to the version that jqueryui required (and which was actually noted very clearly on the demo page; my bad for not reading closely!) it all worked correctly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.