7

I have a partial view and I want to render it in main view using jquery.

Here is how I am coding the jQuery:

$(document).ready(function() {
        $("#dvGames").load("/LiveGame/Partial3");
});

where as controller method looks like this:

public ActionResult Partial3(DateTime gameDate)
{
    return View("Partial3");
}

I dont see anything. I tried

<% Html.RenderPartial("Partial3"); %> 

and it works but I want to filter data in partial view so I am using jquery load method.

1
  • Is the call making into your action method? Do you hit a breakpoint if one is set? Commented Mar 6, 2011 at 12:59

2 Answers 2

15

Your controller action requires a DateTime parameter that you need to supply when invoking the AJAX request:

$(function() {
    $('#dvGames').load(
        '<%= Url.Action("Partial3", "LiveGame") %>', 
        { gameDate: '2011-03-06' }
    );
});
Sign up to request clarification or add additional context in comments.

1 Comment

+1 - also, i think the ActionResult Partial3 should be returning a partialview(), rather than a view()!?
0

Try letting the framework create the URL. Use the

<%= Url.Action("LiveGame","Partial3") %>

5 Comments

It is not going in controller action. and I used <%= Url.Action("LiveGame","Partial3") %> and it is printing: "/Partial3/LiveGame " on the screen. I need to load partial view.
Instead of hard coding the URL in the load, try using the URL.Action method. Also are you supplying the gameDate parameter?
@ rcravens I am used url.action as I mentioned above but it printed the value instead of going to that partial view. I need to supply gameDate parameter. How can I do this ?
Add it as a query parameter. url?gameDate='date'
@rcavens and how to use url.action

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.