Calling a MVC2 partial view using jquery returns empty string problem

Posted by Jason on Stack Overflow See other posts from Stack Overflow or by Jason
Published on 2010-04-15T16:20:08Z Indexed on 2010/04/15 16:43 UTC
Read the original article Hit count: 980

Filed under:
|
|
|

I have an issue where I have a partial view that returns some HTML to be displayed. Its called when something is clicked on the page using jquery. The problem is that no matter how I call it, i get back an empty string even though it reports success. This is happening to me using Chrome, going against my local machine.

My controller looks like this:

public ActionResult MyPartialView()
{
    return PartialView(model);
}

I have tried jquery using .get(), .post() and .load() and all have the same results. Here is an example using .post():

$.post(url, function (data)
{
    alert(data);
});

The result always comes back as an empty string. I can navigate to the partial view in the browser manually and i get back the desired HTML. The URL I am using to call it I resolved fully so it looks like "http://localhost/controller/mypartialview" rather than using the relative path of "/controller/mypartialview" which I thought was the original problem. Any idea what may cause this?

© Stack Overflow or respective owner

Related posts about mvc

Related posts about partial-views