0

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..

2
  • What view engine are you using? Commented Mar 18, 2013 at 20:42
  • sorry, i am using ASP.NET MVC 3. the view page is a .aspx file... if that helps Commented Mar 18, 2013 at 20:45

1 Answer 1

3

Your function does not specify a parameter name.

function RefreshPartial() {
    $('#invited-teams').load('/Challenge/GetInvitedTeams', {
       'paramname' :'<%:Model.ChallengeId %>'//Or your ASP wrapper here
    });
}  
Sign up to request clarification or add additional context in comments.

12 Comments

so, i wrote this, and it doesnt have syntax errors. i have not run it yet.
let me try to run it. might take a few minutes.
Okay... so, it didn't work. What it is doing is it looks like it is going to refresh, and then the whole page goes white. If i hit refresh the page loads back up fine. I set a breakpoint in the method and it is not getting hit..
@user1977591, Do you understand the function of .load()? It loads the content of a page/URL in a specified element. Read here
I just noticed that dakait added some single quotes. ill try that.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.