Unterminated string constant during @Html.Partial from javascript object
问题 var html = '@Html.Partial("_mypartialview")'; $("#container").html(html); I am working in a single page application and I don't want to hide the container div element; instead I want to load the html content into my javascript object. But I get the error: Unterminated string constant. I have tried various methods without any success. Any help as to why I get this error would be really appreciated. 回答1: Like this var html = "@Html.Partial("_mypartialview").ToHtmlString().Replace("\n", "<br/>")