Mautic Community Forums

Form is not working for us

Your software Mautic 4
My PHP version is : 7.4
My MySQL/MariaDB version is (delete as applicable): MySQL/MariaDB version: 8.0

These errors are showing in the Mautic log : none found

Your problem
My problem is : Javascript error on a different domain name other than where Mautic is installed on.

Steps I have tried to fix the problem : The error did show about CORS so I took this disabled CORS, Add domain name in the CORS setting. This error went away however the other two error still remains and I can’t find or figure what causing this error

Test page to see or test the error - BTG Test Form

Domain Mautic is installed on - https://deafcoder.com/

Here the first error:

VM441:1 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

And the second error:

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)
Form.prepareValidation @ mautic-form.js?v1ced89cf:8
Form.prepareForms @ mautic-form.js?v1ced89cf:6
Core.onLoad @ mautic-form.js?v1ced89cf:47
script.onload @ VM434:1
load (async)
(anonymous) @ VM434:1
(anonymous) @ generate.js?id=1:11

1 Like

Can anyone help us with this one?

I have same problem,
Mautic4 & PHP7.4
Mautic3.3.4 & PHP7.4

have 2 errors,
first ==> Uncaught SyntaxError: Unexpected token } in JSON at position 12
@ return JSON.parse(’{"’ + decodeURI(params.trim().replace(/&/g, “”,"").replace(/=/g, “”:"")) + ‘"}’);

second ==> Uncaught TypeError: Cannot read properties of undefined (reading ‘testforms’)
@ if (typeof window.MauticFormValidations[formId] == ‘undefined’) {

Does this forum get any attention from support team???

The ‘support team’ are members of the community just like you - and yes, they are trying to help as many people as they can!

Hi,
I can also see your error:

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)

Did you just insert the form via JavaScript?
Did you set any validation parameters in the form?
Do you use any firewall, like Wordfence?

Thx,
Joey

Adding a link to a GitHub issue:

I inserted on webpage using this -

<script type="text/javascript" src="//deafcoder.com/form/generate.js?id=1"></script>

I set to Yes and added in this text “This cannot be left blank.” in validation message box

Server is a CentOS 7.9 using CSF Firewall - ConfigServer Security & Firewall (csf)

Can u plz check in the setup of your firewall is not messing ip the cors communication?

Oh sorry, just noticed it’s a well documented bug. All good then.

I have cors disabled on the Mautic

Okay, but of your firewall is blocking incoming communication then things also wont work.

However this is not the case, there is a bug clearly.

I fixed my problem, but I don’t known that is good solution for you ,

This seems to be fixed after upgrading to 4.0.1 today

This thread can be closed now.

Thank you …