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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:09:15+00:00 2026-05-24T11:09:15+00:00

I am working on an .NET MVC 3 project where I have made all

  • 0

I am working on an .NET MVC 3 project where I have made all the form based views load in a modal dialog using jQuery.

All of my views are loaded using ajax throughout the project.

I have a jQuery function I call for any link click event which fetches the given url (of a form based view like edit, add, etc) and displays it in a modal dialog as follows:

function getFormInModal(url_location, modalWidth, modaltitle, tab) {
    var url = url_location;
    var dialogDiv = $('<div style="display: none;"></div>').appendTo('body');
    dialogDiv.load(url, function () {
        //Enable the client side validation
        var $form = $('form', dialogDiv);
        $.validator.unobtrusive.parse($form);
        var buttons = {
            "Submit": function () {
                //Create a validation summary container
                var valSummary = ModalForms.validationSummary();
                valSummary.setup($form);
                if ($form.valid()) {
                    var postUrl = $form.attr('action');
                    var formData = $form.serialize();
                    jQuery.ajax({
                        url: postUrl,
                        type: 'POST',
                        data: formData,
                        complete: function (data) {
                            dialogDiv.dialog('close');
                            refresh(tab);
                            $.jGrowl("Submitted Successfully.", { life: 2000 });
                        },
                        error: function (jqXHR, textStatus, errorThrown) {
                            var data = jQuery.parseJSON(jqXHR.responseText);
                            if (data && data.errors) {
                                valSummary.addErrors(data.errors);
                            }
                        }
                    });
                }
            },
            Cancel: function () {
                dialogDiv.dialog('close');
                $("html,body").css("overflow", "auto");
            }
        };
        //Load up the dialog
        dialogDiv.dialog({
            autoOpen: true,
            modal: true,
            title: modaltitle,
            draggable: false,
            resizable: false,
            buttons: buttons,
            width: modalWidth,
            close: function () {
                $(this).remove();
            },
            open: function (event, ui) {
                $("html,body").css("overflow", "hidden");
            }
        });
    });
}

My problem is in the success function of the submit button of the modal.

It does 3 things:
1. Closes the modal form dialog
2. Notifies the user that the POST was successful
3. Refreshes the content in a particular DIV via a call to another simple function refresh().

function refresh(tabname) {
    if (tabname == "dashboard") {
        $("#dashboard-tab").load("/Sales/Home/Reports");
        $("#tabs").tabs("select", 0);
    }
    if (tabname == "leads") {
        $("#leads-tab").load("/Sales/Lead/Index");
        $("#tabs").tabs("select", 1);
    }
    if (tabname == "retail") {
        $("#retail-tab").load("/Sales/Retail/Index");
        $("#tabs").tabs("select", 2);
    }
    if (tabname == "corporate") {
        $("#corporate-tab").load("/Sales/Corporate/Index");
        $("#tabs").tabs("select", 3);
    }
}

Now, separately I have hooked up some events on DOM ready which handle my ajax call status as follows:

$("#loading").dialog({
    autoOpen: false,
    modal: true,
    width: '450px',
    title: 'Patience is a virtue!',
    resizable: false,
    draggable: false
});

$("#loading").ajaxStart(function () {
    $("#loading").dialog('open');
    $("html,body").css("overflow", "hidden");
});

$("#loading").ajaxSuccess(function () {
    $("#loading").dialog('close');
    $("html,body").css("overflow", "auto");
});

$("#loading").ajaxError(function (event, jqXHR, ajaxSettings, thrownError) {
    $("#loading").dialog('close');
    $.jGrowl(html(thrownError.toString()), { life: 2000 });
});

Everything works perfectly –
– I click on a link
– I see the #loading modal dialog
– It loads and the #loading closes and the dialogDiv modal opens
– I click submit and the #loading opens up on top of the dialogDiv
– When it is done both close and i get the jGrowl notification

The final step which is the loading of the content again also happens, however once my POST is done, and the .load() call is made to refresh content the #loading modal does not show again.

Basically, .ajaxStart() is not firing. I do not know why.

First I had written an success function for the ajax post made in the submit button’s click event. Then I realized that complete might be better.

Even now, thou I am calling the refresh() and hence the .load() after the completion of the only other live .ajax() call, the .ajaxStart() is not working.

Can someone please HELP!!

  • 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-24T11:09:15+00:00Added an answer on May 24, 2026 at 11:09 am

    The only thing I can see would be the current ajax request is still being processed when you call the refresh function, which is causing your ajaxStart method to not fire. Try editing your ready() method to add a beforeSend method to your ajax settings. I have found ajaxStart to always act weird, which is why usually the beforeSend is a little more reliable (imo).

    $(document).ready({
       $.ajaxSetup({
          beforeSend: function()
          {
             $('#loading').open();
             $('html,body').css('overflow', 'hidden');
          }
       });
       /* Rest of your initialization here */
    });
    

    Hope this helps and will work for you.

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

Sidebar

Related Questions

I'm working on a Web project using Asp.Net MVC, which I'll have to deploy
I'm working on asp.net MVC 3 form. I made sure to have the recaptcha.dll,system.web.helpers
background:Me and my coworkers are working on asp.net mvc project ... we have a
I'm working with an ASP.NET MVC 2 project using a classic ASP.NET WebForm wired
I'm working on an asp.net-mvc project. I have an Items table and a Tags
I'm working in an ASP.NET MVC project where I have created a two LinqToSQL
I am working on a ASP .NET mVC project & i have to change
I am working on asp.net MVC 3 project. I am using EF 4.1 code
I am using T4MVC in our ASP.NET MVC project. I have a statement like
I am currently working on a ASP.NET MVC 3 project in which I have

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.