0
votes

I have very weird problem, I'm trying to render partial view with model on my page.My controller action send html to browser (FireBug show me desired html response from server), but browser doesn't render it! screenshot of firebug output _ViewStart.cshtml

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

_Layout.cshtml

<!DOCTYPE html>
<html>
<head>
  //...
</head>
<body>
<div class="container">
    @Html.Partial("HeaderPartialView")
    <div class="row">
        <div class="col-md-3" id="LeftPane" style="border-width:3px">
            @Html.Action("LeftPane", "Nav")
        </div>
        <div class="col-md-9" id="Content">
            @RenderBody()
        </div>
    </div>
    @Html.Partial("FooterPartialView")
</div>
</body>
</html>

Controller action invokes by javascript $.post('/Query/GetUserQuery', { jsonQuery: jsonString }); and just deserialise json into object, which I pass as model to my shared View.

public ActionResult GetUserQuery(string jsonQuery) {
    //Deserialization jsonQuery -> result
    return PartialView("_ShowData", result);
}

Please, help me. I had no troubles with partial views before, looks like I miss something important.

1
The script you have shown is not adding the partial you receive to the DOM (you need to do it in the success callback) - user3559349
If you are using ajax. Can you share the code? - Kumar_Vikas
@Kumar_Vikas, looks like Stephen was right I don't added success callback, in case you're asking to check it. - PilgrimViis
Go ahead and add a success callback and try. - Kumar_Vikas

1 Answers

0
votes

Thanks for @StephenMuecke I got it. Stephen if you post your comment as answer I'll accept it, for the time being I post this maybe it'll help somebody in future.

For make things work I just added success callback. Very simple, how I can forget about it?

            $.post('/Query/GetUserQuery', { jsonQuery: jsonString })
            .done(function (data) {
                $('#Results').append(data);
            });