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 9001047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:23:07+00:00 2026-06-16T00:23:07+00:00

I am using jQuery’s UI Dialog to draw a dialog ( my-ui-dialog ) to

  • 0

I am using jQuery’s UI Dialog to draw a dialog (my-ui-dialog) to the screen and present the user with some <input>s and other controls. When the user clicks the dialog’s OK button, I want the UI dialog to fire an AJAX/JSON message to my server (via getJSON), allow the server to process that call, and then close the dialog after the response is received from the server. Then the user should be redirected (via window.location) to another web page.

Here’s my code:

$("#my-ui-dialog").dialog({
    modal: true,
    autoOpen: false,
    height: 255,
    width: 300,
    buttons: {
        "OK" : function() {
            var f = $("#fizz").val();

            $.getJSON(
                "/myserver/do-something",
                {
                    fizz: f
                },
                function() {
                    $("#my-ui-dialog").dialog('destroy');
                }
            );

            // When I leave this in the code works great.
            // When I comment the alert out, the getJSON call never
            // hits the server-side.
            alert("Returned from the backend...");

            window.location = "/myserver/some-other-url"
            $(this).dialog("close");
        },
        Cancel : function() {
            $(this).dialog("close");
        }
    }
});

When I leave that alert box in, and wait a few seconds (with the alertbox drawn to screen), the getJSON method seems to have enough time to hit the server and return. But if I comment out the alert the request never even hits my server. I can tell this by adding a log message to the beginning of the handler listening at /myserver/do-something. This is also a Java web app and I don’t see any evidence of Tomcat receiving the request, and I don’t see the HTTP request being generated when using Firebug to debug. All 3 of these indicate that the request is simply not hitting the server at all.

What are my options here? Can I make the jQuery sleep for a few seconds? That feels like an ugly solution; there must be a better way to use the jQuery API… thanks in advance!

  • 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-06-16T00:23:08+00:00Added an answer on June 16, 2026 at 12:23 am

    Put your dialog close and window.location code in the getJSON callback. That’s why there’s a callback.

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

Sidebar

Related Questions

Using jQuery I want to check if checkboxes or radio button inside a div
Using jQuery, how can I get the input element that has the caret's (cursor's)
Using jQuery I want to give a specific element the same width (or min-width
Using jQuery/jQueryUI I want to populate a form using this HTML/JS show below. The
Using Jquery, I want to build a table of size 4x4 with equal sized
Using jQuery validation - validating on blur: $('input, select, radio, checkbox').blur(function(){ $(#createAccount).validate().element(this); }); If
Using jQuery or something similar, is it possible to detect when a user has
Using jQuery, I am referencing a particular ID and then I want to add
Using jquery, I want to post data to from one of my pages to
Using jQuery autocomplete.. Want to replace hello in script below with javascript to identify

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.