javascript - How to use jQuery to reload Partial with new parameter -
i have partial view load in page passing in parameter. when page loads, setup 2 parameters helpmember
, helpanonymous
.
{ var helpmember = model.content.children.where(c => c.documenttypealias.equals("contextualhelp", stringcomparison.currentcultureignorecase)).elementat(0); var helpanonymous = model.content.children.where(c => c.documenttypealias.equals("contextualhelp", stringcomparison.currentcultureignorecase)).elementat(1); }
<div id="contextual-help-partial" > @html.partial("contextualhelp", helpmember) </div>
with jquery, how can reload partial , pass helpanonymous
it?
you have create 1 method in controller , call action using this. suppose created action loadhtml
. return partialview action.
controller action as
public actionresult loadhtml(string helpmember){ viewbag.helpmember = helpmember; return partialview("contextualhelp"); }
jquery code
$.ajax({ type: 'get', url: "/loadhtml?helpmember=@helpmember", datatype:"html", success: function (data) { $("#contextual-help-partial").empty().html(data); }, error: function (err) { } });
Comments
Post a Comment