Jump to content

SyntaxError: Unexpected token <


bluellyr
 Share

Recommended Posts

Hi,

I don't know if this is the right forum but, anyone knows what to do when this error happens?

SyntaxError: Unexpected token <


#3 Object.parse (native) 



Thank you

Link to comment
Share on other sites

Hi,

I didn't manage to understand exactly what happened but a college of mine did installed some modules that were not for this PW version.

This error was shown when we tried to upload an image with the image field type.

This is a small site and we manage to setup all the work in a few hours.

Thank you for your replies.

Link to comment
Share on other sites

I've been getting this error since yesterday, too, when trying to upload an image. I set up a fresh installation without any custom module to verify if a lately installed module causes this behaviour.

But the error appears in that fresh installation as well. If I change the PHP version, the image upload works fine without any problem. Today I tried to reproduce that error on another computer - no luck, everything works as expected. Same PHP (5.6.18) and ProcessWire (2.7.3) version, both running with nginx.

The new image gets uploaded, but the image doesn't appear right after the upload. I have to save the page to see the image. If I disable JavaScript I can upload an image without an error message.

So in my case it's depending on the environment (and not on ProcessWire), but I haven't figured out for now what the problem/difference is. I got that error message while uploading an image already some month ago, but after some updates everything was fine again. 

Link to comment
Share on other sites

Check the output that is returned from the Ajax request, maybe you get a hint what's causing it server side, e.g. PHP warning or HTML message.

You can do this for example in chrome with with the dev tools under "Network". Select the XHR request and choose "Response".

Link to comment
Share on other sites

.. resolved the issue in less than three minutes, yesterday I was too lazy to take a closer look (in other words: my battery was empty).

Edit php.ini, to avoid this warning set 'always_populate_raw_post_data' to '-1', restart php and the message is gone  ;)

; Always populate the $HTTP_RAW_POST_DATA variable. PHP's default behavior is
; to disable this feature and it will be removed in a future version.
; If post reading is disabled through enable_post_data_reading,
; $HTTP_RAW_POST_DATA is *NOT* populated.
; http://php.net/always-populate-raw-post-data
always_populate_raw_post_data = -1

Before:

post-2759-0-88388400-1455053583_thumb.pn

<br />
<b>Deprecated</b>:  Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in <b>Unknown</b> on line <b>0</b><br />
<br />
<b>Warning</b>:  Cannot modify header information - headers already sent in <b>Unknown</b> on line <b>0</b><br />
[{"error":false,"message":"Added file: body.png","file":"\/site\/assets\/files\/1\/body.png","size":26952,"markup":"\n\t<li id='file_60984d6634e55217fe6424485038dd7d' class='InputfieldFileItem InputfieldImage ui-widget'>\n\t\t<p class='InputfieldFileInfo InputfieldItemHeader ui-widget ui-widget-header ui-helper-clearfix'>\n\t\t\t<span class='HideIfSingle HideIfEmpty InputfieldFileDrag'><i class='fa fa-sort'><\/i> <\/span>\n\t\t\t<i class='fa fa-caret-right InputfieldFileDrag HideIfMultiple'><\/i> \n\t\t\t<label class='InputfieldFileDelete'><input type='checkbox' name='delete_images_60984d6634e55217fe6424485038dd7d' value='1' title='Delete' \/><i class='fa fa-fw fa-trash'><\/i><\/label>\n\t\t\t<a class='InputfieldFileMove InputfieldFileMoveBottom' href='#' title='Move to bottom'><i class='fa fa-fw fa-angle-double-down'><\/i><\/a> \n\t\t\t<a class='InputfieldFileMove InputfieldFileMoveTop' href='#' title='Move to top'><i class='fa fa-fw fa-angle-double-up'><\/i><\/a> \n\t\t\t<a class='InputfieldFileName pw-modal pw-modal-large' title='body.png: body.png (720x101)' href='\/processwire\/page\/image\/edit\/?id=1&file=1,body.png&rte=0&field=images' data-buttons='#non_rte_dialog_buttons button' data-autoclose='1' data-close='#non_rte_cancel'>body.png <i class='fa fa-pencil ui-priority-secondary'><\/i><\/a> \n\t\t\t<span class='InputfieldFileStats'>26 kB, 720x101  <\/span> \n\t\t<\/p>\n\t\t<div class='InputfieldFileData ui-widget ui-widget-content'>\n\t\t\t<div class='InputfieldImagePreview'>\n\t\t\t\t<a class='InputfieldFileLink' target='_blank' href='\/site\/assets\/files\/1\/body.png?nc=10'><img height=\"100\" src=\"\/site\/assets\/files\/1\/body.0x100.png?nc=1455052838\" alt=\"\" data-gridsize=\"100\"  \/><\/a>\n\t\t\t\t<div class='InputfieldImageActions'>\n\t\t\t\t\t<a title='body.png (720x101)' href='\/processwire\/page\/image\/edit\/?id=1&file=1,body.png&rte=0&field=images' class='pw-modal pw-modal-large' data-buttons='#non_rte_dialog_buttons button' data-autoclose='1' data-close='#non_rte_cancel'><i class='fa fa-fw fa-crop'><\/i><\/a>\n\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t\t<div class='InputfieldFileDescription'><label for='description_images_60984d6634e55217fe6424485038dd7d' class='detail'>Description<\/label><input type='text' name='description_images_60984d6634e55217fe6424485038dd7d' id='description_images_60984d6634e55217fe6424485038dd7d' value='' \/><\/div>\n\t\t\t<input class='InputfieldFileSort' type='text' name='sort_images_60984d6634e55217fe6424485038dd7d' value='2' \/>\n\t\t<\/div>\n\t<\/li>","replace":false,"overwrite":0}]
  • Like 8
Link to comment
Share on other sites

  • 1 year later...

A follow to my previous post:

I think this a weird problem. I tried it with some images and it turns out that only images form Adobe Stock have this problem ?????? also Fotolia (wich are the same but different payment options) Shutterstock is no problem. 

Even if I resize/crop the Adobe Images the problem remains …

So I think I just don't use Adobe Stock…

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...