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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:25:13+00:00 2026-05-11T10:25:13+00:00

I have a simple form that is used to update an entity in my

  • 0

I have a simple form that is used to update an entity in my ASP.NET MVC app. I want the user to be able to submit the form, have the proper Action on my controller be called and then notify the user that the update was completed.

Because I wanted to display a JQuery dialog after the user clicks the update button, I wanted to use JQuery to submit the form. However, my problem is this:

While I can easily get JQuery to call an action on my controller, I can’t get it to call an action that I’ve already setup in my route and that has been decorated with [Authorize] and [AcceptVerbs(HttpVerbs.Post)]

For example, if the user is updating their entity at the following URL:

/SomeController/Edit/5 

When JQuery submits the form, I want to submit it to my Edit Action that is already decorated and accepts the ID as a parameter.

The JQuery I am using to post the form is as follows:

$('#formFoo').submit(function() {                 var frm = $('#formFoo');                 var action = frm.attr('action');                 var serializedForm = frm.serialize();                 $.post(action, serializedForm, function() {                     alert('Call completed');                 });                 return false;             }); 

If I define my form as follows:

<form id='formFoo' action='/SomeController/SomeOtherAction' method='post'> 

and my Action as follows:

public void SomeOtherAction()  {     var myEntity=new MyEntity();     UpdateModel(myEntity); } 

Then my action is called and my object is populated properly, but it’s ID field isn’t populated, so I don’t know what entity I am updating.

If I change my form to:

<form id='formFoo' action='/SomeController/Edit' method='post'> 

and I have my Edit action defined as:

[Authorize,AcceptVerbs(HttpVerbs.Post)] public void Edit(int id, FormCollection collection) 

Then my action never seems to be called by JQuery.

I suppose I could somehow pull the ID parameter off of the querystring and stuff that into the data that I’m posting back to the form, but that seems very ugly. Or is there a way I can get the ID field while in in my SomeOtherAction action? Or am I just going about this all 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. 2026-05-11T10:25:13+00:00Added an answer on May 11, 2026 at 10:25 am

    When you call:

    $.post(action 

    Then the ‘action’ argument needs to include the ID. In your question, you don’t say what this is at runtime, but I strongly suspect it does not include the ID. Based on your sample URI for your Edit action, the ID should be in the path of the URI, not in the query. With the default MVC route it shouldn’t make any difference, but without knowing what your routes are I would say that you should stick closely to the URI format that you give in the question.

    So install firebug, if you haven’t already, put a breakpoint in the JavaScript, and inspect the value of the action argument.

    If it still looks right, open the Net panel of Firebug, click the XHR option, and look at the actual URI generated by your code. Make sure it is correct. If the URI is not correct, then look at your routes and make sure that this URI will be correctly routed to the right action.

    Finally, but me that in a plug for the jQuery Ajax Form plug-in. I find that it makes this sort of thing very easy.

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

Sidebar

Related Questions

I have an ASP.NET form that the user can make lots of changes to,
I have a simple contact form with Subject and Message that I want to
I have a simple windows form app that I need to get the file
I have a simple form that looks like so <% remote_form_for post, :url =>
I have a simple form that searches through the 2000+ issues of a 3rd
I currently have a simple form that when you click the save button will
I'm creating a form. As of right now I have simple MAILTO form that
I have a simple Windows Form that hosts property controls at runtime. When the
I have a simple html form that is structured something like this: <form name=test
I have started using jQuery and rails. I have made a simple form that

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.