Page 1 of 1

Syntax Error: Unexpected token < in JSON at position 0

Posted: Mon Jun 06, 2016 4:46 pm
by matchamr
Hello,

Can anyone help with an issue I have when going to edit an order as an opencart administrator.

I get an error message titled 'Syntax Error: Unexpected token < in JSON at position 0'

The body of the messsage appears as per the attachment.

When I try to click on the other tabs on the screen such as 2.Products, 3. Payment Details, 4. Shipping Details I cannot go into them and a no entry sign appears as the cursor.

Thank you for any guidance anyone can offer.

Richard

Re: Syntax Error: Unexpected token < in JSON at position 0

Posted: Mon Jun 06, 2016 4:51 pm
by i2Paq
This error appears quite often in other installs.

Have you used our FREE search on: JSON at position 0.

Re: Syntax Error: Unexpected token < in JSON at position 0

Posted: Mon Jun 06, 2016 6:04 pm
by artcore
Try this in your htaccess

Code: Select all

    <IfModule mod_rewrite.c>
      RewriteCond %{HTTPS} !=on
      RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
      RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
    </IfModule>
Ajax needs same domain and with WWW is considered another domain.
If you don't know about htaccess do a forum/google search ;)

Re: Syntax Error: Unexpected token < in JSON at position 0

Posted: Mon Jun 06, 2016 6:11 pm
by i2Paq
artcore wrote:Try this in your htaccess

Code: Select all

    <IfModule mod_rewrite.c>
      RewriteCond %{HTTPS} !=on
      RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
      RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
    </IfModule>
Ajax needs same domain and with WWW is considered another domain.
If you don't know about htaccess do a forum/google search ;)
Could you explain what this does?

In my .htaccess I have this:

Code: Select all

# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/

RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
This is somewhat different from what you advice.

Re: Syntax Error: Unexpected token < in JSON at position 0

Posted: Mon Jun 06, 2016 7:28 pm
by artcore
Yours says: if not www then add it in.
Mine removes WWW. It depends on your config urls and preferences. www is esentially a subdomain of the main. I like them clean. ajax requests don't work cross domain so they have to match!

Re: Syntax Error: Unexpected token < in JSON at position 0

Posted: Tue Jun 07, 2016 3:27 am
by matchamr
Hello Both,

Thank you kindly for taking the time to assist. I have copied both of your codes into my htaccess file, however the same result occurs. My entire htaccess file in the root directory reads (I've also tried the other suggestion): (note I am using journal2 them - will this make a difference?) Any suggestions? Thank you.

htaccess:
AddType x-httpd-php54 .php

<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
</IfModule>

Re: Syntax Error: Unexpected token < in JSON at position 0

Posted: Tue Jun 07, 2016 4:23 am
by artcore
If that is the only content in your htaccess, you should get a fresh copy from the opencart download section first and optionally add the addition.

To solve your issue, try this:

Go to Admin > Settings > Users > API
Create a new API and enable it
Next, go to Store Settings
Under Option tab in the Checkout section > API user > select
Save

Re: Syntax Error: Unexpected token < in JSON at position 0

Posted: Thu Sep 13, 2018 8:44 pm
by frtyaman
Image

Hello there, why am I getting the error shown in the picture how to fix?

Error message I get after setting smtp server
Image

Re: Syntax Error: Unexpected token < in JSON at position 0

Posted: Mon Sep 17, 2018 4:15 pm
by OSWorX
As you can see at the message: mail has been disabled (because of what reason ? ).
Fix that and it should work.

Re: Syntax Error: Unexpected token < in JSON at position 0

Posted: Mon Sep 17, 2018 9:13 pm
by straightlight
It is possible that your host might be using POP before SMTP authentication or SMTP via SSL which is why the mail function has been disabled. Either switch to SMTP options or contact your host to resolved this issue. Not an OC bug, posted in the wrong section.