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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:04:12+00:00 2026-06-05T17:04:12+00:00

I want to render the partial view using ajax. When I submit the button,

  • 0

I want to render the partial view using ajax.
When I submit the button, the partial view must be rendered.
I could implemented it using ActionLink but I want to call the Action by JavaScript.
But the following code doesn’t work. The Action is called but the partial view does not be rendered.

View

@section script{
<script type="text/javascript">
    function test() {
        $.ajax(
        {
            type: "POST",
            url: "Test",
            data: "",
            success: function (result) { alert("OK!!"); },
            error: function (req, status, error) {
                alert("Damn!!");}
        });


    }
</script>
}

<input type="submit" onclick="test()" />
<div id="Container">

Controller

public ActionResult Test()
{
    if (Request.IsAjaxRequest())
    {
        return PartialView("ViewUserControl1");
    }
    return View();
}

Partial View ViewUserControl1

Hello world

This works but is not what I want to do

@Ajax.ActionLink("click me", "Test", new AjaxOptions { UpdateTargetId = "Container" })
  • 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-05T17:04:13+00:00Added an answer on June 5, 2026 at 5:04 pm

    Your url may not be correct. It dependent on your routing settings
    defined in Global.asax . But usually your url should look like
    “/Home/Test” if your action is in HomeController. It’s better to use
    url helper for getting actions’ urls:

    ...
    url: '@Url.Action("Test", "Home")'
    ...
    

    You can render your partial in next way:

    ...
    success: function (result) { $('#elementId').html(result) },
    ...
    

    Also if you want to update block, don’t forget to clear it first and if it contains form with unobtrusive validation – parse form.

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

Sidebar

Related Questions

I want to render a PartialView inside a <iframe src=''></iframe> The rendered partial view
In my Application_Error event handler i want to render an MVC-View for 404. I
In my view, I have a form I want to dynamically render. This form
I'm trying to AJAX-ify the Django contact_form app using Django (1.4.2). I want to
I am having difficulty rendering a partial view using the MVC3 razor engine. When
I am using jQuery to do an ajax call to my controller, and everything
I want to designing an application Where i need to generate some partial view
I have a partial view that is a search textbox and button. I am
I am using multiple partial views on my View. on the left-hand side. I
I have a cshtml partial view (Razor engine) that is used to render something

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.