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

  • Home
  • SEARCH
  • 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 8495907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:42:20+00:00 2026-06-10T23:42:20+00:00

I created a basic MVC app. For the home view I made a Create.cshtml

  • 0

I created a basic MVC app.

For the home view I made a Create.cshtml page with:

<h2>title Create</h2>

On the home controller I added the get method:

public ActionResult Create(int id)
        {
            return View();
        }

On my Index.cshtml view I have:

@{
    ViewBag.Title = "Home Page";
}
<h2>@ViewBag.Message</h2>
<p>
    To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">
        http://asp.net/mvc</a>.
</p>
<div class="clicky">click me</div>
<script type="text/javascript">
    $(function () {
        $(".clicky").click(function () {
            $.get('@Url.Action("Create")', { id: "1" }, function () {

            });
        });
    });
</script>

Imagine my surprise when I ran it and found that when click me was clicked the screen didn’t change.

I put a breakpoint on Create and found the method was indeed being entered. Also firebug was showing no sign of error.

I then changed the script as follows:

<script type="text/javascript">
        $(function () {
            $(".clicky").click(function () {
                //$.get('@Url.Action("Create")', { id: "1" }, function () {

                //});

                window.location.href = '/Home/Create/1';
            });
        });
    </script>

The app now worked as expected returning the Create view.

Could someone please explain to me why my former method did not work?

  • 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-10T23:42:24+00:00Added an answer on June 10, 2026 at 11:42 pm

    Your former method sends an asynchronous request to the server. The returned data (in this case your rendered create view) is passed back into your javascript callback method which is empty in your sample:

    $.get('@Url.Action("Create")', { id: "1" }, function (data, textStatus, jqXHR) {
    
    });
    

    Try adding the parameters to your callback funktion and set a javascript breakpoint at the function. You will see, that the html is passed in the data parameter.
    You could use it to render it in some div or in a dialog like this:

    function (data, textStatus, jqXHR) {
        // simply put it in a div
        $("#mydiv").html(data);
        // or open a jquery dialog
        $("#mydiv").html(data).dialog();
    });
    

    Or you could use one of the Ajax helpers like Ajax.ActionLink

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

Sidebar

Related Questions

I've created a basic MVC REST API to just get single Person from the
I created a basic Spring MVC / JPA / Hibernate app. I am trying
I lack understanding of some basic MVC concepts, despite all my searching. I created
I am trying to get latitude and longitude of user. I created a basic
I have simple jQuery Mobile site created using asp.net mvc 2 and uses basic
I have a basic MVC 2 beta app where I am trying to implement
Starting my way with STS and created a new basic Hello World Spring MVC
I've just create a new MVC project, and have made no changes at all,
I'm new to ASP.NET MVC 3 and I'm trying to create a edit view
I've created a basic MVC 3 website that's using Windows Azure's Access Control Service

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.