Errors when submitting a Sitecore Form from a page, where the "Storefront Branded Theme" SXA theme is used


Description

On submitting a Sitecore Experience Form on a page with the "Storefront Branded Theme" commerce SXA theme, errors in the browser console appear:

Uncaught TypeError: Cannot read property 'parse' of undefined
    at HTMLFormElement.eval (eval at c (jquery.unobtrusive-ajax.min.js:19), <anonymous>:3:130)
    at Object.success (jquery.unobtrusive-ajax.min.js:19)
    at l (jquery-2.1.3.min.js:14)
    at Object.fireWith [as resolveWith] (jquery-2.1.3.min.js:14)
    at p (jquery-2.1.3.min.js:14)
    at XMLHttpRequest.<anonymous> (jquery-2.1.3.min.js:14)
Uncaught TypeError: Cannot read property 'parse' of undefined
    at Object.eval (eval at i (optimized-min.js?t=20180517T132054Z:19), <anonymous>:3:130)
    at Object.success (optimized-min.js?t=20180517T132054Z:19)
    at c (optimized-min.js?t=20180517T132054Z:14)
    at Object.fireWith [as resolveWith] (optimized-min.js?t=20180517T132054Z:14)
    at b (optimized-min.js?t=20180517T132054Z:14)
    at XMLHttpRequest.<anonymous> (optimized-min.js?t=20180517T132054Z:14)

Solution

  1. Remove "jquery-2.1.3.min.js" from the "Scripts" field of the Form item.
  2. Modify the "\Views\SxaLayout\SxaLayout.cshtml" file so that SXA scripts are rendered at the top of the page:
    <head>
      @foreach (string style in assetLinks.Styles)
      {
        @Html.Raw(style)
      }
      @foreach (string script in assetLinks.Scripts)
     {
       @Html.Raw(script)
     }
      @Html.Sitecore().VisitorIdentification()