Uncaught Loaded Unexpected Element While Trying to get Rendering HTML From Server

Expecting last tag to be closing script marker

June 3, 2017

We were simply trying to add a component to a placeholder in edit mode but every time we inserted it and hit OK, the page returned this JS error: Uncaught Loaded unexpected element while trying to get rendering html from server. Expecting last tag to be closing script marker

Uncaught loaded unexpected element error

Here was our master view HTML:


<!-- Main.cshtml -->
<!-- Main Content-->
<div class="row">
	@Html.Sitecore().Placeholder("content")
</div>

Here was our downstream view HTML with the placeholder we were trying to insert a component into:


<!-- LandingPage.cshtml -->
<div class="components">
	@Html.Sitecore().Placeholder("landing-page")
</div>

When Googling for a solution, we were advised by a few blogs to:

  • Populate the "Datasource location" field on the component
  • Properly enclose the content into valid HTML markup

In our case, we had done both of these things, but the real problem turned out to be more insidious. After gutting our LandingPage.cshtml view and rewriting it, we were able to insert a component with no issues. This tells me that there was something about the view syntax or encoding that Sitecore somehow could not handle.

Im summary, if you get this error and have already populated the "Datasource location" field of the component and have enclosed the content in valid HTML, try starting from scratch and retype your views manually. Your real problem could be Visual Studio or whichever text editor you're using!