Mautic Community Forums

Javascript embed form error

I am getting this error when trying to embed a form into my website using javascript

The form loads fine but doesn’t submit or anything. The errors appears instantly as the page loads.

What I need to do to troubleshoot this?

Thank you
Bill

Uncaught SyntaxError: Unexpected token } in JSON at position 12
at JSON.parse ()
at Object.Core.parseToObject (mautic-form.js?v1ced89cf:47)
at mautic-form.js?v1ced89cf:48
at mautic-form.js?v1ced89cf:49
mautic-form.js?v1ced89cf:8 Uncaught TypeError: Cannot read properties of undefined (reading ‘btgsubscriptionform’)
at Object.Form.prepareValidation (mautic-form.js?v1ced89cf:8)
at Object.Form.prepareForms (mautic-form.js?v1ced89cf:6)
at Object.Core.onLoad (mautic-form.js?v1ced89cf:47)
at HTMLScriptElement.script.onload (:1:491)
mautic-form.js?v1ced89cf:17 Uncaught ReferenceError: MauticFormValidations is not defined
at Object.validateForm (mautic-form.js?v1ced89cf:17)
at Object.Core.validateForm (mautic-form.js?v1ced89cf:39)
at HTMLFormElement.theForm.onsubmit (mautic-form.js?v1ced89cf:6)
validateForm @ mautic-form.js?v1ced89cf:17
Core.validateForm @ mautic-form.js?v1ced89cf:39
theForm.onsubmit @ mautic-form.js?v1ced89cf:6
mautic-form.js?v1ced89cf:8 Uncaught TypeError: Cannot read properties of undefined (reading ‘btgsubscriptionform’)
at Object.Form.prepareValidation (mautic-form.js?v1ced89cf:8)
at Object.Form.prepareForms (mautic-form.js?v1ced89cf:6)
at Object.Core.onLoad (mautic-form.js?v1ced89cf:47)
at :1:746
at generate.js?id=1&=1631213448124:11
Form.prepareValidation @ mautic-form.js?v1ced89cf:8
Form.prepareForms @ mautic-form.js?v1ced89cf:6
Core.onLoad @ mautic-form.js?v1ced89cf:47
(anonymous) @ VM57:1
(anonymous) @ generate.js?id=1&
=1631213448124:11

I just test it using the manual approach by c/p the html into my webpage and the form works as intended. I would like to try at least get the automatic javascript embed working instead.

Here the link to the test page BTG Test Form Check the JS error in browser console.

There is no error recorded on server side logs or in mautic log on this.