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

  • Home
  • SEARCH
  • 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 6590945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:21:47+00:00 2026-05-25T17:21:47+00:00

again. I have a script that is using the jQuery UI plugin to generate

  • 0

again.
I have a script that is using the jQuery UI plugin to generate inline modal windows, as such:

function openModal(src, width, title){
    $("#" + src).dialog({
        modal: true,
        width: width,
        title: title,
        resizable: false,
        show: 'fade',
        hide: 'fade'
    });
    $('.ui-widget-overlay').hide().fadeIn();
    return false;
}

$(document).ready(function() {
    $('#newTopicBtn').click(function(e) {
        e.preventDefault();
        openModal('newTopic', 650, 'New Topic');
    });
});

The modal window pops up just as it should.

Most of these modal windows open forms of some sort. The problem is that when the form is submitted, and processed by the script, i can’t seem to get the form’s modal to close by itself when i use $('#newTopic').dialog("close"):

$('#newTopic_form').bind('submit', function() {
    var error = '';

    var topicTitle = $('input[name=newTopicTitle]').val();
    var topicBody = $('textarea[name=newTopicBody]').val();

    if(topicTitle == '' || topicTitle.length < 2)
    {
        error = error + '<br />You must enter a longer title.';
    }
    if(topicBody == '' || topicBody.length < 2)
    {
        error = error + '<br />You must enter a longer topic.';
    }

    if(error != '')
    {
        $('#newTopicError').css("display","none");
        $('#newTopicError').html(error);
        $('#newTopicError').fadeIn(1000);
    }
    else
    {
        var pageUrl = window.location.search;
        var pattern = /mode=viewcat&id=(\d+)&title/gi;
        var catID = pageUrl.match(pattern);

        var data = 'mode=newTopic&cat_id=' + catID + '&title=' + encodeURIComponent(topicTitle) + '&content=' + encodeURIComponent(topicBody) + '&u=' + usrId;
        $.ajax({
            url: "data.php",
            type: "POST",
            dataType: "json",
            data: data,
            cache: false,
            success: function(data) {
                if(data.response == 'added')
                {
                    $('#newTopicError').css("display", "none");
                    $('#newTopicError').html("You have added your topic.");
                    $('#newTopicError').fadeIn(1000);
                    setInterval(10000, function(){
                        $('#newTopic').dialog("close");
                    });
                }
            }
        });
    }
    return false;
});

The form submits and is processed perfectly fine, and the correct strings are faded into the modal’s form response area, but the window never closes.

There is also an issue with my RegEx, as it only returns null instead of the catID, if anyone wants to help out with that one, too. 🙂

  • 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-25T17:21:48+00:00Added an answer on May 25, 2026 at 5:21 pm

    I think

    setInterval(10000, function(){
        $('#newTopic').dialog("close");
    });
    

    should be:

    setTimeout(function(){
        $('#newTopic').dialog("close");
    }, 10000);
    

    The original code has its parameters in the wrong order, and it says that you want to close the dialog every 10 seconds. The new code has the parameters in the right order, and will only execute once, 10 seconds from being set.

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

Sidebar

Related Questions

I have created a dynamic list picker script using Jquery 1.3 and PHP that
I am using the jQuery Validation plugin and have an issue validating items that
Again I have a question regarding this plugin: http://t.wits.sg/2008/06/20/jquery-progress-bar-11/ What I want to achieve
I have a jQuery script that appends a row to a table. In short,
I have been developing and testing with inline jQuery. I am using CodeIgniter and
I am working on a comment script using ajax, json and jquery. I have
I have a basic HTML file, using jQuery's ajax, that is connecting to my
I have recently encountered a problem in IE, using the jQuery UI datepicker script:
I have a Create-View like this ... <script src=@Url.Content(~/Scripts/jquery.validate.min.js) type=text/javascript></script> <script src=@Url.Content(~/Scripts/jquery.validate.unobtrusive.min.js) type=text/javascript></script> @using
I have created a nice tooltip box using JQuery and I used some plugin

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.