Fix Element ‘script’ Character Content Not Allowed Error – Magento 2

catalogsearchmagento2magento2.2.2

I am running my custom plugin in Magento 2.2.2 fresh install.

I have customised Magento search page. When I hit search page then below error comes.

enter image description here

It's working perfectly in Magento 2.1 and 2.2.0 but not working in Magento 2.2.2.

Below is the code which I am using.

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <script src="Vendor_ModuleName::js/timer.js" type="text/javascript"></script>
    </head>
    <body>
        <referenceBlock name="search_result_list" template="Vendor_ModuleName::product/list.phtml">
        </referenceBlock>
    </body>
</page>

Best Answer

I have solved this issue by changing below line.

<script src="Vendor_ModuleName::js/timer.js" type="text/javascript"></script>

change with

<script type="text/javascript" src="Vendor_ModuleName::js/timer.js"/>
Related Topic