Jump to content
munvera

Impossible add product to the cart : Unexpected syntax < in JSON at position 0

Recommended Posts

Hi,

 

 

My shop encountered the suddenly issue when I was trying to add product to cart as a user.

 

textStatus: 'parsererror'
errorThrown: 'SyntaxError: Unexpected token < in JSON at position 0'
responseText:
 
Can anyone help me? I have been searching for answer in the forum but none of it works for me.
 
Appreciate your help. 
 
 

Share this post


Link to post
Share on other sites

The issues only happens in product page when I logged in to user account. 

I can add product to cart without user account and only logged in during checkout and proceed to payment.

Any suggestion please?  :(

 

https://www.prestashop.com/forums/topic/537680-user-becomes-not-logged-in-at-product-page/

 

I posted another issue previously and just realised both of them might be related?

Please help me! Your help will be greatly appreciated. 

 

To be precise, I can add product to cart without user account and only logged in during checkout. 

Edited by munvera (see edit history)

Share this post


Link to post
Share on other sites
I see you have a lot of errors in your shop, without know which could be the issue, you could never be solved.

 

 

Please try to follow this steps, I hope this help you to identify the cause...

 

1.- If you have a custom theme, disable it and change to the default theme, many time people install custom themes without be 100% compatibles with their PrestaShop version.

 

2.- In the "Back Office > Advanced parameters > Performance" there is to insteresting options to disable non PrestaShop modules and override files, turn on both options and check of problem is gone.

 

3.- Finally, it is recommended to enable the debug mode to show possible errors in the code, if you don't know how to do this, search on google or here in the forum, there is a lot of info about this in the web.

 

 

Hope this help you!

Share this post


Link to post
Share on other sites

Hi sir,

 

I have tried everything. http://test.schuhster.com/en/classy-formal/86-sandford-black.html here is my test site.. Forgot about the theme, I tried to change to default theme but doesn't resolve my problem.  :(  It is really weird because it works without account logged in.  :(  :(

 

Edited..

 

I found that when I logged in to user account and click to product page, the ajax cart return the index page in response. Only happens in product page  :o  :o

Edited by munvera (see edit history)

Share this post


Link to post
Share on other sites

OH NO!

 

I disabled Friendly URL option and it works! But I wish to enable the option for SEO.

 

I tried disabled Friendly URL > force compilation and clear cache > enable Friendly URL , the errors still exists.  :o

Share this post


Link to post
Share on other sites

You should look with Firefox/firebug what happens. You can then see what is sent and what is received in the Ajax command that transport the product to your cart. See the attached images:

 

post-302430-0-15668700-1466503048_thumb.jpgpost-302430-0-05239900-1466503049_thumb.jpg

Share this post


Link to post
Share on other sites

Hi,

 

Just install firebug, I didn't realised that this is much useful than chrome developer tools  :o. [ Just my personal opinion. :)  ]

 

I checked my product page when logged in, the information in firebug as follows.

 

------------------------------------------------------------------------------------------------------------------------------------------------

 

URL :  ?rand=1466562100780 

Status : 302 Moved Temporarily

 

Post (Parameters)

ajax : true

controller : cart

token : 486f4b245a54886d4ac976d5b9ec4b77

 

Response 


 

 

How could it be?  :unsure:  :unsure:

Edited by munvera (see edit history)

Share this post


Link to post
Share on other sites

Just install firebug, I didn't realised that this is much useful than chrome developer tools  :o.

I don't think so, developer tools of chrome is much better and faster, you don't need install firebug to do this kind of review.

 

 

Talking about your issue, sometimes the file permissions cause errors, files should be at 0644 and folders at 0755

 

In the SEO & URLs tab, my recommendation is that, both the domain and SSL domain use the prefix www, eg; www.myshop.com

Share this post


Link to post
Share on other sites
Hello,
I am developing a module that among other functions I want to send me an email to the client that I selected and with the files they attach.
When I upload files through code:
$ Fields_form = array (
'Form' => array (
'Legend' => array (
'Title' => $ this-> l ('Email Receipt Form'). '=> Client Name:'. $ Name_customer. ' - Email: '. $ Email_customer.' - Client language: '. $ Name_lang,
'Icon' => 'icon-cogs'
),
'Input' => array (
Array (
'Type' => 'text',
'Label' => $ this-> l ('Email Client'),
'Name' => 'email',
'Search' => false,
'Orderby' => false,
'Align' => 'center',
),
Array (
'Type' => 'text',
'Label' => $ this-> l ('E-mail copy'),
'Name' => 'ACCOUNT_EMAIL',
'Search' => false,
'Orderby' => false,
'Align' => 'center',
'Desc' => $ this-> l ('Check if this is the email you want to send a copy of the email sent.')
),
Array (
'Type' => 'file',
'Label' => $ this-> l ('Attach documents'),
'Name' => 'FILE',
'Search' => false,
'Orderby' => false,
'Align' => 'center',
'Desc' => $ test,
(to be continued)
 
 It works flawlessly, but only sends one attachment at a time.
I wanted to now send more than one attachment through what I did in the following code:
$ Fields_form = array (
'Form' => array (
'Legend' => array (
'Title' => $ this-> l ('Email Receipt Form'). '=> Client Name:'. $ Name_customer. ' - Email: '. $ Email_customer.' - Client language: '. $ Name_lang,
'Icon' => 'icon-cogs'
),
'Input' => array (
Array (
'Type' => 'text',
'Label' => $ this-> l ('Email Client'),
'Name' => 'email',
'Search' => false,
'Orderby' => false,
'Align' => 'center',
),
Array (
'Type' => 'text',
'Label' => $ this-> l ('E-mail copy'),
'Name' => 'ACCOUNT_EMAIL',
'Search' => false,
'Orderby' => false,
'Align' => 'center',
'Desc' => $ this-> l ('Check if this is the email you want to send a copy of the email sent.')
),
Array (
'Type' => 'file',
'Label' => $ this-> l ('Attach documents'),
'Name' => 'FILE',
'Search' => false,
'Orderby' => false,
'Align' => 'center',
'Desc' => $ test,
'Ajax' => true,
'Multiple' => true,
),
(to be continued)
Result:
Unexpected token < in JSON at position 0
 
 
This code uploads multiple files but I can not get it to work.
I can not get the second image code to work.
Someone can help me"?

 

Thank you

Share this post


Link to post
Share on other sites
On 6/21/2016 at 2:09 AM, Rolige said:
I see you have a lot of errors in your shop, without know which could be the issue, you could never be solved.

 

 

 

 

 

 

 

Please try to follow this steps, I hope this help you to identify the cause...

 

 

 

 

 

1.- If you have a custom theme, disable it and change to the default theme, many time people install custom themes without be 100% compatibles with their PrestaShop version.

 

 

 

 

 

2.- In the "Back Office > Advanced parameters > Performance" there is to insteresting options to disable non PrestaShop modules and override files, turn on both options and check of problem is gone.

 

 

 

 

 

3.- Finally, it is recommended to enable the debug mode to show possible errors in the code, if you don't know how to do this, search on google or here in the forum, there is a lot of info about this in the web.

 

 

 

 

 

 

 

 

Hope this help you!

 

after enable debug mode the error will be shown

currently, I use theme is

specialdev213-bootstrap version 2.0 

please help to fix the problem

Screenshot_1.png

Screenshot_2.png

Screenshot_3.png

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More