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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:22:47+00:00 2026-05-29T13:22:47+00:00

I am having a problem with a form submitted in MVC. it is able

  • 0

I am having a problem with a form submitted in MVC. it is able to be loaded from 2 different points and from one it submits and the second it does not post back.

It is a partial view loaded inside of a JQuery modal dialog. When I trigger the modal from the home page it will submit fine.

There is another modal which can be launched to allow a user to find a task that would then allow for the launch of a second modal to show the form. When this same form is submitted it does not trigger a post to the controller.

Here is the JQuery script:

$(document).ready(function () {
    var title =$(this).attr("data-dialog-title");

        $(".NoteDialog").live("click", function (e) {

            e.preventDefault();
            if ($(this).attr("data-dialog-title") != "Find Task") 
            {
                if ($(this).attr("data-dialog-id") == "deleteDialog") {
                    $("<div id='formModal'><img src='../../Content/images/ajax-loader.gif' /></div>")
                    .addClass("dialog")
                    .attr("id", $(this).attr("data-dialog-id"))
                    .appendTo("body")
                    .dialog({
                        width: 300,
                        position: [600, 50],
                        title: $(this).attr("data-dialog-title"),
                        close: function () { $(this).remove() },
                        modal: true,
                        buttons: {
                            "Delete": function () {
                                $("#form0").submit();
                                $(this).dialog("close");
                            },
                            Cancel: function () {
                                $(this).dialog("close");
                            }
                        }
                    })
                .load(this.href);
                }
                else 
                {
                    $("<div id='formModal'><img src='../../Content/images/ajax-loader.gif' /></div>")
                    .addClass("dialog")
                    .attr("id", $(this).attr("data-dialog-id"))
                    .appendTo("body")
                    .dialog({
                        width: 800,
                        position: [300, 50],
                        title: $(this).attr("data-dialog-title"),
                        close: function () { $(this).remove() },
                        modal: true,
                        buttons: {
                            "Save": function () {
                                alert('Handler for .submit() called.');
                                $("#form0").submit();
                                $(this).dialog("close");
                            },
                            Cancel: function () {
                                $(this).dialog("close");
                            }
                        }
                    })
                .load(this.href);
                }
            }
            else 
            {
                $("<div id='formModal'><img src='../../Content/images/ajax-loader.gif' /></div>")
                    .addClass("dialog")
                    .attr("id", $(this).attr("data-dialog-id"))
                    .appendTo("body")
                    .dialog({
                        width: 860,
                        position: [300, 50],
                        title: $(this).attr("data-dialog-title"),
                        close: function () { $(this).remove() },
                        modal: true
                })
                .load(this.href);
            }
    });

    $(".close").live("click", function (e) {
        e.preventDefault();
        $(this).closest(".dialog").dialog("close");
    });
});

It is used for launching both modal dialogs. The Alert occurs and the close dialog occurs also so the script is processing, just not submitting.

The partial view creates the form using @using (Ajax.BeginForm("AddTime","TimeTracker", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "TimeForm" }))

The form tag produced both times is:

<form action="/TimeTracker/AddTime?AddID=183336&TypeID=1&_=1328710484230" data-ajax="true" data-ajax-method="POST" data-ajax-mode="replace" data-ajax-update="#TimeForm" id="form0" method="post">

Is there a different way to submit?
I tried having the buttons as part of the form itself which worked but had a different problem; the cancel button wouldn’t close the modal correctly, causing multiple modals to be triggered each subsequent launch. If that was able to be remedied, I could sidestep this non-posting issue.

Update: I just found a possible issue/clue when running through the scenario in Firebug with the XHR tab. It appears that the form posts to the FindTask method which is what handles the first modal. It should be posting to the AddTime method which is what occurs when called from the home page.

Why does the AJAX not post to the action specified in the form tag?

It is also sending the post used for the FindTask modal and not the form fields from the AddTime form when submitted.

  • 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-29T13:22:47+00:00Added an answer on May 29, 2026 at 1:22 pm

    The issue turned out that MVC was assigning the same form id to both dialog forms. It would submit the first it found which was the wrong one.

    Once I assigned a specific ID for the form I was able to direct which form to submit.

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

Sidebar

Related Questions

Having a problem where the form submits before the validateUsername function has a chance
I'm having a little problem with form submission with jquery. I've submitted a lot
I am having problem that when i am trying to submit the form by
I'm having a problem with a simple form where i'm attempting to fire an
I am having a problem assigning a default value to my Spring Form input
I am working on a windows form project and having some problem with UserControl
I'm having a little problem with jQuery: I'm having .submit() defined on a form,
I'm having problems stripping the tags from the textual inputs retrieved from my form
Having problem with the middle Div not expanding to the width http://acs.graphicsmayhem.com/images/middiv.jpg Ok, how
Hi there I am having a problem with my form validation, basically the problem

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.