WordPress.org

Forums

Loco Translate
[resolved] Error: SyntaxError: Unexpected token (14 posts)

  1. mattvd
    Member
    Posted 1 year ago #

    Hi there.

    Thanks for the plugin, however, everytime I try to save the translation I get this error

    Error: SyntaxError: Unexpected token <

    Also, do your translations save if your translating a plugin and you update that plugin?

    https://wordpress.org/plugins/loco-translate/

  2. timwhitlock
    Member
    Plugin Author

    Posted 1 year ago #

    Your error sounds like the Ajax services is returning HTML instead of JSON. Usually this is due to an unrecoverable PHP error. We need to find out what that error says. You can do that either by looking in your error logs, or inspecting the Ajax request in your browser dev tools.

    If you can tell me what the error says, I might be able to help.

    In answer to your second question - updating the plugin will probably overwrite all existing files including PO and MO files.

    If the plugin update adds new translatable strings, those changes should be reflected in the plugin's own POT file if it has one.

    I'd recommend backing up the PO files you've modified and putting them back after the update. Then opening each one in the Loco editor, running the "sync" operation and then saving again if all is well.

  3. mattvd
    Member
    Posted 1 year ago #

    Hello. Hopefully this will help. This is the error I got when trying to save a translation

    http://postimg.org/image/vw0l69vav/

  4. timwhitlock
    Member
    Plugin Author

    Posted 1 year ago #

    Nearly there.
    If you select that item and hit the Preview tab, you will see the rendered HTML for the error, this will probably contain the words describing the PHP error.

  5. mattvd
    Member
    Posted 1 year ago #

    Sorry about that... for some reason I can't replicate the error within my console... is there someway to send you my login details so you would possibly be able to look at the error yourself? Whenever I click save and the error pops up, no error is popping up in the console.

    Thanks!

  6. timwhitlock
    Member
    Plugin Author

    Posted 1 year ago #

    I don't follow what you mean about not being able to replicate the error.
    I can see from your screenshot that the error is there to be viewed. Are you saying it's no longer happening?

  7. mattvd
    Member
    Posted 1 year ago #

    I'm afraid so. Whenever I try to save a translation, I'm still getting the same error
    Error: SyntaxError: Unexpected token <

    However, nothing shows up in the console like it did before in my previous screenshot.

  8. timwhitlock
    Member
    Plugin Author

    Posted 1 year ago #

    It's possible the response is cached if it's not showing up.
    Clear your browser cache and try again.

  9. mattvd
    Member
    Posted 1 year ago #

    Hi there. Thanks for all of your help. I cleared my cache and tried again and unfortunately no error. I did try in firefox but got a completely different error
    Error: SyntaxError: JSON.parse: unexpected character

    Not sure if that helps at all?

  10. mattvd
    Member
    Posted 1 year ago #

    Hi there,

    Would really love to use your plugin as it's the only one on the market that looks like it will work for me... just need to get passed this small hiccup.

    Is it possible for me to give you login details to my site for you to take a look at the error?

    I also went into my files via ftp and pulled up the php error log and I have no errors in the log referring to your plugin. Could this be a plugin conflict of some sort?

  11. timwhitlock
    Member
    Plugin Author

    Posted 1 year ago #

    please email details to support at localise dot biz.

  12. mattvd
    Member
    Posted 1 year ago #

    Just reporting back.. this was infact an issue with my hosting company... not an issue with the plugin. Works great now thanks for the awesome plugin!

  13. drayks
    Member
    Posted 10 months ago #

    Hi, im having the same issue, we just moved Host.

    What was the solution to this?

  14. timwhitlock
    Member
    Plugin Author

    Posted 10 months ago #

    There is nothing to say your problem is the same. This will occur if any Ajax request responds with something other than valid JSON. Please open a new ticket with the output of the offending Ajax request, plus any errors in your log files.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Loco Translate
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.