jQuery syntax error?
Question by user1977591
I found an example here on stackoverflow that I am trying to recreate and use a solution.
here is the link to the example: Refreshing Partial View in MVC 3
what is wrong with my syntax?
function RefreshPartial() {
$('#invited-teams').load('/Challenge/GetInvitedTeams', {Model.ChallengeId});
}
will this work? or does it need to have the curly brackets?
function RefreshPartial() {
$('#invited-teams').load('/Challenge/GetInvitedTeams', "<%= Model.ChallengeId %>" );
}
UPDATE:
function RefreshPartial() {
$('#invited-teams').load('/Challenge/GetInvitedTeams',
{'paramname' : <%:Model.ChallengeId %> });
}
my partial view:
<div id="invited-teams">
<% Html.RenderPartial("InvitedTeams", Model.InvitedTeams); %>
</div>
So, this is what my refreshPartial method is looking like:
function RefreshPartial() {
alert("in refresh partial");
alert("<%:Model.ChallengeId %>");
$('#invited-teams').load('/Challenge/GetInvitedTeams', {
'paramname': '<%:Model.ChallengeId %>'
});
}
it alerts both alerts correctly, with the 2nd one having the correct ChallengeID. The page is still going blank though. hmm..
Answer by Starx
Your function does not specify a parameter name.
function RefreshPartial() {
$('#invited-teams').load('/Challenge/GetInvitedTeams', {
'paramname' :'<%:Model.ChallengeId %>'//Or your ASP wrapper here
});
}