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

Expecting last tag to be closing script marker

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

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

<!-- LandingPage.cshtml -->
<div class="components">

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!

👋 Hey Sitecore Enthusiasts!

Sign up to our bi-weekly newsletter for a bite-sized curation of valuable insight from the Sitecore community.

What’s in it for you?

  • Stay up-to-date with the latest Sitecore news
  • New to Sitecore? Learn tips and tricks to help you navigate this powerful tool
  • Sitecore pro? Expand your skill set and discover troubleshooting tips
  • Browse open careers and opportunities
  • Get a chance to be featured in upcoming editions
  • Learn our secret handshake
  • And more!
Sitecore Snack a newsletter by Fishtank Consulting