Note that there are some explanatory texts on larger screens.

plurals
  1. POPartialViewResult action gives error when ran from jquery function but not from @Render.Action
    primarykey
    data
    text
    <p>I have an action that when I was working on during development was called by an @Html.Render action, rendered the partial view and worked just fine.</p> <p>That partial view was rendering a table which inside had another @Html.RenderAction for each TR. Like this:</p> <pre><code>&lt;div id="fooDiv"&gt; @{Html.RenderAction("ProjectData", "Functional", new { categoryId = Model.SelectedCategoryId});} &lt;/div&gt; </code></pre> <p>Which renders several other Partials one of which is:</p> <pre><code>&lt;div id="FuncTableWrapper"&gt; @{Html.RenderAction("FuncTable", Model.Id);} &lt;/div&gt; </code></pre> <p>Which renders:</p> <pre><code>&lt;table id="funcTable"&gt; &lt;tr&gt; &lt;th&gt;&lt;/th&gt; @foreach (var item in Model.Categories) { &lt;th class="thFuncLangName"&gt;@item.Name&lt;/th&gt; } &lt;/tr&gt; @foreach (var funcFeature in Model.FuncFeatures) { &lt;tr&gt; &lt;td class="tdfuncFeatureName" colspan="@(Model.Categories.Count() + 1)"&gt;@funcFeature.Name&lt;/td&gt; &lt;/tr&gt; &lt;tr class="trAddFuncContent hideThis"&gt; &lt;td colspan="@(Model.Languages.Count() + 1)"&gt; @{Html.RenderAction("AddFuncContent", new { funcFeatureId = funcFeature.Id });} &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>This works fine. However, the render should not be done on page load but only when I click on a tab, I decided to call that action from jquery and populate the div I needed at that point.</p> <pre><code>$("#FuncData").click(function () { $.ajax({ type: "POST", url: '@Url.Action("ProjectData", "Functional")', data: { "CategoryId": @(Model.SelectedCategoryId) }, dataType: "html", success: function(result) { populateDiv($("#fooDiv"), data); } }); }); </code></pre> <p>When I do that I know get an error on the RenderAction calling the "AddFuncContent" action saying that "Child actions are not allowed to perform redirect actions."</p> <p>What difference is there between the page calling Html.RenderAction and javascript calling my action?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload