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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:51:53+00:00 2026-06-05T07:51:53+00:00

What i want to do: at page load to automatically pop up a jquery

  • 0

What i want to do:

at page load to automatically pop up a jquery dialog fill in some data, post that to an action and close the dialog (regardless if the action succeeds or not).

in the View in which the pop up should occur i have the following:

<script type="text/javascript">
    $(function () {
        $('#PopUpDialog').dialog(
            {
                modal: true,
                open: function ()
                {
                    $(this).load('@Url.Action("Subscription", "PopUp")');
                },  
                closeOnEscape: false
            }
        );

        $('.ui-dialog-titlebar').hide();
        $('#closeId').live('click',function () {
                $('#PopUpDialog').dialog('close');               
                return false;
            }
        );

            $('#SubscriptionForm').submit(function () {
                $("#PopUpDialog").dialog("close");             
                $.ajax({
                    url: encodeURI('@Url.Action("Subscription", "PopUp")' ),
                    type: this.method,
                    data: $(this).serialize()
                })
                return fase;
            }
            );
    });
</script>

the Subscription view has the following:

@using (Html.BeginForm( new { id = "SubscriptionForm" }))
{

    @Html.ActionLink(Deals.Views.PopUp.SubscriptionResources.AlreadySubscribed, "", null, new { id = "closeId" })
    <br />
    <br />
    @Deals.Views.PopUp.SubscriptionResources.FillEmail 
    @Html.TextBoxFor(m => Model.Email)    
    <input type="submit" id="subscribeId" value="@Deals.Views.PopUp.SubscriptionResources.IWantToSubscribe"  />
    <br />    
}

which works fine.

The POST action is defined as follows:

[AcceptVerbs(HttpVerbs.Post)]
        public JsonResult Subscription(FormCollection formValues)
        //public void Subscription(FormCollection formValues)
        {
            Deals.ViewModels.PopUpSubscriptionVM VM = new ViewModels.PopUpSubscriptionVM();
            TryUpdateModel(VM);
            if (!String.IsNullOrEmpty(VM.Email))
            {
                //do the update to the dbms
            }
            return Json(new { success = true });
        }

The problem is that after posting back i get an empty screen with the success message, which i don’t want!
What am i doing wrong?

  • 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-05T07:51:55+00:00Added an answer on June 5, 2026 at 7:51 am

    To see what i am doing wrong i set up a small project (ASP.NET MVC 3) with the following ingredients:

    <script type="text/javascript">
    
        $(function () {
            // Does not cache the ajax requests to the controller e.g. IE7/9 is doing that...
            $.ajaxSetup({ cache: false });
    
            var $loading = $('<img src="@Url.Content("~/images/ajax-Loader.gif")"  alt="loading" class="ui-loading-icon">');
            var $url = '@Url.Action("Subscription", "PopUp")';
            var $title = 'Some title';
            var $dialog = $('<div></div>');
            $dialog.empty();        
            $dialog
                .append($loading)            
                .load($url)
                .dialog({
                    autoOpen: false
                    , closeOnEscape: false
                    , title: $title
                    , width: 500
                    , modal: true
                    , minHeight: 200
                    , show: 'fade'
                    , hide: 'fade'
                });
    
            $dialog.dialog("option", "buttons", {
                "Cancel": function () {
                    $(this).dialog("close");
                    $(this).empty();
                },
                "Submit": function () {
                    var dlg = $(this);
                    $.ajax({
                        url: $url,
                        type: 'POST',
                        data: $("#SubscriptionForm").serialize(),
                        success: function (response) {
                            //$(target).html(response);
                            dlg.dialog('close');
                            dlg.empty();
    
                    });
                }
            });
    
    
            $dialog.dialog('open');
        })
    </script>
    

    The controllers’ actions:

    public ActionResult Subscription()
            {
    
                Thread.Sleep(2000); //just for testing
                TestModalAjax.ViewModels.PopUpVM VM = new ViewModels.PopUpVM();
                return View(VM);
            }
    
    
            //POST
            [AcceptVerbs(HttpVerbs.Post)]
            //[OutputCache(CacheProfile = "ZeroCacheProfile")]
            public ActionResult Subscription(FormCollection formValues)
            {
                TestModalAjax.ViewModels.PopUpVM VM = new ViewModels.PopUpVM();
                TryUpdateModel(VM);
                return Json(new { success = true });
    
            }
    

    …and the according View:

    @model TestModalAjax.ViewModels.PopUpVM
    @{
        Layout = null;
        ViewBag.Title = "Subscription";
    }
    
    <h2>Subscription</h2>
    @* -----   NOTICE THE FOLLOWING!!! WITHOUT THIS DATA GETS NOT POSTED BACK!!!! ----  *@
    @using (Html.BeginForm("Subscription","PopUp",FormMethod.Post, new { id="SubscriptionForm"})) 
    {
        <h1> Give me your name</h1>
        @Html.TextBoxFor(M => Model.Name)
    }
    

    …so it seems everything works as expected!

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

Sidebar

Related Questions

I want on page load for the class of a li tag to be
I want to fake a simple animation on page load by sequentially revealing several
I want to get exception of page load, but still have not results on
Hi I want to set opacity for a form in page load. I try
I want to display images on a .net page which I load from database
I have a product listing page and want to load up a detail view
I want to load google.com into a page in my site. I tried using
Hello Friends check my code http://jsfiddle.net/sUaky/2/ i want to load a web page in
I'm using the YUI Uploader component and want to automatically open the browse dialog
I have a HTML table in a page <table id=options_table></table> I want to automatically

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.