简体   繁体   中英

ASP/MVC - Switch a partial view in javascript code

I have table on my view page. One of the cells has an ID (say "x"). When a certain button is clicked a JS function is called, and the purpose is to dynamically change the partial view contained inside that cell using the code:

$("#X")[0].innerHTML = @Html.Partial("PartialViewName");

It works perfectly on firefox, but not in IE8. Also, FIY,the partial view is an AJAX form.

You can load the partial view by ajax like this using Jquery load ,

$("#X").load(@Url.Action("action","controller"));

and in the controller you have to return the partial view like this,

public ActionResult Action(){  
    return PartialView('PartialViewName')
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM