mailtrain-wordpress-plugin icon indicating copy to clipboard operation
mailtrain-wordpress-plugin copied to clipboard

wordpress plugin issue: Unexpected end of JSON input

Open nezam05 opened this issue 9 years ago • 8 comments

I am getting this error from the wordpress widget of this plugin Unexpected end of JSON input

nezam05 avatar Apr 18 '17 05:04 nezam05

Just to verify, are you running Mailtrain v1.23.2 plus this patch? Also, when checking your browsers DevTools Console, is there any more info?

witzig avatar Apr 18 '17 07:04 witzig

Mailtrain version is v.1.23.2. Not sure about the patch as I am running on cloudron.

I was getting a different browser error earlier, something more like err name resolution. now getting this (index):1 XMLHttpRequest cannot load https://marketing.pompom.com.bd/subscription/SJy5k0fhe/widget. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://futurestartup.com' is therefore not allowed access. The response had HTTP status code 403.

nezam05 avatar Apr 18 '17 08:04 nezam05

You need to enable CORS:

  1. Enable cross-origin resource sharing in your Mailtrain config file and whitelist your site

Yet I'm not sure if you're able to edit the config file on cloudron ...

witzig avatar Apr 18 '17 08:04 witzig

Its enabled in my installation and the website is whitelisted.

nezam05 avatar Apr 18 '17 08:04 nezam05

http://futurestartup.com is not in your whitelist, only http://www.futurestartup.com is.

Your config should look like this:

[cors]
# Allow subscription widgets to be embedded
origins=["http://futurestartup.com", "http://www.futurestartup.com"]

Still, if you want widgets to work with custom forms, you need the patch mentioned above.

witzig avatar Apr 18 '17 08:04 witzig

Hi, I have modified the config file and it now looks like the above. However, now getting this on browser console OPTIONS https://marketing.pompom.com.bdsubscription/SJy5k0fhe/subscribe net::ERR_NAME_NOT_RESOLVED sendForm @ widget.js?ver=4.7.3:102 (anonymous) @ widget.js?ver=4.7.3:141

it seems the list url is missing a / after .com.bd

nezam05 avatar Apr 18 '17 09:04 nezam05

it seems the list url is missing a / after .com.bd

Yeah, the cause is here, yet the ServiceURL in Mailtrain should actually save with a trailing slash.

On your Mailtrain Settings Page, could you verify (or manually add) the trailing slash to your Service URL?

witzig avatar Apr 18 '17 10:04 witzig

Adding a slash solves the issue. Thanks.

nezam05 avatar Apr 18 '17 12:04 nezam05