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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:10:47+00:00 2026-06-07T11:10:47+00:00

I am using MVC 3, c# on IE9 In my controller I have the

  • 0

I am using MVC 3, c# on IE9
In my controller I have the following 2 ActionResuls that is of significance:

    public ActionResult EditTrain(String trainid)
    {
       ....
       return PartialView(edittrain);
    }


    [HttpPost]
    public ActionResult EditTrain(Train editrain)
    {
       ....
       DataContext.SubmitChanges();      
       return RedirectToAction("Edit", new { id = trainid });                  
    }

On the partial view, I have the following code:

    @model Models.EditTrain
    @{
       ViewBag.Title = "Training";
    }

    <h2>Train</h2>
    @using (Html.BeginForm(null, null, FormMethod.Post, new { id = "theForm" }))
    {
      @Html.ValidationSummary(false)

      @Html.HiddenFor(model => model.ID)

      <div class="display-label" style="font-weight: normal">
       @Html.Label("ID:")
      </div>
      <div class="display-field">
       @Html.DisplayFor(model => model.ID)
      </div>   

      <div class="display-label" style="font-weight: normal">
        @Html.Label("KitID:")
      </div>
      <div class="display-field">
       @Html.DisplayFor(model => model.KitID)
      </div> 

      <div class="editor-label">
         @Html.Label("Inactive:")
      </div>
      <div class="editor-field">
         @Html.EditorFor(model => model.Inactive)
      </div>    

      <div class="editor-label">
       @Html.Label("Inactive Date:")
     </div>   

     <div id='datepicker' class="editor-field">
       @Html.EditorFor(model => model.InactiveDate)
     </div> 
      ......
      <div style="clear:left;"> 
       <br />         
       <p>
        <input type="submit" id="submit" value="Submit" />
       </p>
      </div> 
    }  

   <script type="text/javascript">

   $.ajaxSetup({ cache: false }); 

   $(document).ready(function () {

     $("#submit").click(function () {

       $.ajax({
               type: "POST",
               url: url,
               data: $('#theForm').serialize()
             });

       $("#stlist").load('@Url.Action("KitsEdit","Spr")' + '?id=' +  '@Model.sprid');

     });
   });

In the above code, what I like to happen above is that once the user clicks on submit, I like it to go to the following action:

    [HttpPost]
    public ActionResult EditTrain(Train editrain) 

and then return back to the View and run the following code

       $("#stlist").load('@Url.Action("KitsEdit","Spr")' + '?id=' +  '@Model.sprid');

What is happening though is that it does the above but after it runs

    $("#stlist").load('@Url.Action("KitsEdit","Spr")' + '?id=' +  '@Model.sprid'); 

it runs

    [HttpPost]
    public ActionResult EditTrain(Train editrain)

a second time.

How can I prevent it from going to

    [HttpPost]
    public ActionResult EditTrain(Train editrain) 

after the .load().

  • 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-07T11:10:49+00:00Added an answer on June 7, 2026 at 11:10 am

    You should return false from your .click() handler. But looking at your code there is something conceptually wrong with it. You call the .load method immediately after firing off your AJAX request without even waiting for this AJAX request to finish. Also there is very little point in invoking a controller action that does a redirect to another action using AJAX.

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

Sidebar

Related Questions

Using MVC-3, Razor: -- MyController -- public ActionResult Index(String message) // where message =
im using mvc framework and i have learned some techniques that help me with
Despite I have been using MVC in PHP many times, I found out that
I'm using MVC with /<module>/<controller>/<action>/ have a module at example.com/module/whatever, and I need to
I'm using MVC 2 and EF4. I have a view that displays my Application
When using MVC, which controller should Terms of Service, Privacy, Help, About actions belong
Im using MVC-Viewmodel, EF Model first on my project. I have a foreach loop
I am using MVC 3 architecture in my project. I have a master page
I am using MVC C# along with Jquery. I have a partial view in
I'm new to using MVC and I'm trying to make a model that uses

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.