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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:10:52+00:00 2026-05-31T16:10:52+00:00

I am interested in creating an AJAX form submit in a jQuery overlay. I

  • 0

I am interested in creating an AJAX form submit in a jQuery overlay. I am not sure how to approach this, do I just toss a partial view into the overlay?

I want to pass to the server the data in the form of a model so I can save it the the data base, I need to be able to create some sort of indication as to whether or not the request succeed. Can anyone guide me through this?

I am kinda new with AJax.

  • 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-31T16:10:53+00:00Added an answer on May 31, 2026 at 4:10 pm

    You could use jQuery UI Dialog. For example let’s suppose that you have a view model:

    public class MyViewModel
    {
        public string Foo { get; set; }
    
        [Required]
        public string Bar { get; set; }
    }
    

    and a controller:

    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }
    
        public ActionResult Modal()
        {
            return PartialView(new MyViewModel());
        }
    
        [HttpPost]
        public ActionResult Modal(MyViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return PartialView(model);
            }
    
            return Json(new { success = true });
        }
    }
    

    In this example the Index action will serve the main view which will simply contain a link allowing to show the form as a modal dialog.

    Here’s the Index.cshtml view:

    @Ajax.ActionLink(
        "show form in modal", 
        "modal", 
        new AjaxOptions { OnSuccess = "onModalLoad" }
    )
    
    <div id="modal"></div>
    

    and the Modal.cshtml partial which will contain the form:

    @model MyViewModel
    
    @using (Ajax.BeginForm(new AjaxOptions { OnSuccess = "onSubmitSuccess" }))
    {
        <div>
            @Html.LabelFor(x => x.Foo)
            @Html.EditorFor(x => x.Foo)
            @Html.ValidationMessageFor(x => x.Foo)
        </div>
        <div>
            @Html.LabelFor(x => x.Bar)
            @Html.EditorFor(x => x.Bar)
            @Html.ValidationMessageFor(x => x.Bar)
        </div>
    
        <button type="submit">OK</button>
    }
    

    The last step is to wire everything using javascript. Here are the 2 callbacks used:

    var onModalLoad = function (result) {
        $('#modal').html(result).dialog();
    }
    
    var onSubmitSuccess = function (result) {
        if (!result.success) {
            $('#modal').html(result);
        } else {
            alert('thanks for submitting');
            $('#modal').dialog('close');
        }
    };
    

    and that’s it.

    Don’t forget to reference the jquery-ui and jquery.unobtrusive-ajax scripts to your page:

    <script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am interested in creating a form in an iphone application similar to this
I'm interested in creating a plugin that does this simple task: Steps 1. User
I'm interested in creating a macro for eliminating the unused variable warning. This question
I'm interested in creating a horizontal scroll view that snaps to the viewed item,
Sorry, for the simplistic question. I am not sure if all of this is
I'm interested in creating a game that uses fractal maps for more realistic geography.
I am interested in creating a website entirely in silverlight (personal reasons) but I
I'm interested in creating a sort of hand-off authentication method, where there's a client
I am interested in creating a web app that uses JSP , Servlets and
I am interested in creating a simple web application that will take in user

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.