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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:56:49+00:00 2026-05-30T23:56:49+00:00

I am trying to understand the difference between JsonResult and Ajax.BeginForm work? Can someone

  • 0

I am trying to understand the difference between JsonResult and Ajax.BeginForm work? Can someone be kind enough to give examples of each? Can the functionality of each be accomplished by JQuery? If so, how?

Thanks

  • 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-30T23:56:50+00:00Added an answer on May 30, 2026 at 11:56 pm

    JsonResult is just a kind of ActionResult derived class that indicates that this action will return JSON instead of a view or something else.

    For example:

    public ActionResult Foo()
    {
        var model = new MyViewModel
        {
            Foo = "bar"
        };
        return Json(model);
    }
    

    This controller action, when invoked, returns the JSON serialized representation of the model:

    {"Foo":"bar"}
    

    In addition to that it sets the Content-Type HTTP response header to application/json.

    Ajax.BeginForm is an HTML helper used to generate a <form> element but which will be submitted using AJAX to the server. So if you point this form to the controller action returning JSON you will be able to retrieve the results of this JSON in the success callback. The results will be automatically parsed into a javascript object that you can access its properties.

    For example:

    @using (Ajax.BeginForm("foo", "home", new AjaxOptions { OnSuccess = "onSuccess" }))
    {
        @Html.EditorFor(x => x.SomeProperty)
        <button type="submit">OK</button>
    }
    

    This will generate a <form> element which will send an AJAX request when submitted to the Foo action. For this to work you need to include the following script to your page:

    <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
    

    Now all that’s left is to write this onSuccess javascript function and process the JSON results returned by the server:

    <script type="text/javascript">
        var onSuccess = function(result) {
            alert(result.Foo);
        };
    </script>
    

    Can the functionality of each be accomplished by JQuery?

    Behind the scenes when you include the jquery.unobtrusive-ajax.js, all forms or links that were generated with Ajax.* helpers will automatically be parsed and AJAXified with jQuery. The HTML5 data-* attributes that those helpers generated will be processed and turned into AJAX calls.

    You could of course decide to use plain jQuery and none of the Ajax.* helpers. In this case you don’t need including the jquery.unobtrusive-ajax.js script. You don’t need using any of the Ajax.* helpers.

    To generate the form you could use a normal Html.BeginForm helper:

    @using (Html.BeginForm("foo", "home", FormMethod.Post, new { id = "myform" }))
    {
        @Html.EditorFor(x => x.SomeProperty)
        <button type="submit">OK</button>
    }
    

    and then in a javascript file use jQuery to subscribe to the .submit event of this form, cancel the default synchronous submission by returning false and sending an AJAX request instead:

    $(function() {
        $('#myform').submit(function(){
            $.ajax({
                url: this.action,
                type: this.method,
                data: $(this).serialize(),
                success: function(result) {
                    alert(result.Foo);
                }
            });
            return false;
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can't understand the difference between count and sum I'm trying to get the
I am trying to understand difference between those two and really need a explanatory
I'm trying to understand the difference between a squash and a rebase. As I
I am trying to understand the difference between this: if (isset($_POST['Submit'])) { //do something
I'm trying to understand the difference between sequences and lists. In F# there is
I'm really trying to understand the difference between OpenID and OAuth? Maybe they're two
Been trying my best to understand this correctly. What is the difference between an
I'm trying to understand the difference between regular Memcache and Doctrine's MemcacheCache. In my
I was trying to understand the difference between early and late binding, and in
I am trying to understand the difference between message-oriented and stream-oriented protocols. I've searched

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.