MVC - Using Ajax to render partial view

前端 未结 3 1191
误落风尘
误落风尘 2020-12-15 10:10

I have this markup in an MVC app.

<% Recipe recipe = (Recipe)Model; %> <% Html.RenderPartial(\"Ingredie
相关标签:
3条回答
  • 2020-12-15 10:18

    Might be worth ensuring that you have correctly referenced the ajaxmvc and jquery scripts in your page (master page). If these are incorrect a new page will be displayed instead of the correct output in the target div.

    0 讨论(0)
  • 2020-12-15 10:29

    RenderPartial takes an action name, not the name of the user control, so replace "IngredientsListControl" with "UpdateStep2", your action name.

    0 讨论(0)
  • 2020-12-15 10:41

    When you use this:

    <a href="javascript:document.forms[0].submit()">
    

    ...you should be aware that it's not the same as

    <input type="submit" />
    

    It doesn't raise the onsubmit event, and MVC's AJAX eventhandler is not called.

    To confirm this is the issue, add

    <input type="submit" /> 
    

    inside the form and try it out.

    Finally, just call onsubmit() from your link

    <a href="#" onclick="document.forms[0].onsubmit()">
    
    0 讨论(0)
提交回复
热议问题