• Resolved rafaviana

    (@rafaviana)


    Hi,
    I run the import with one folder and it worked well. But now when I try to run other folders or only one folder I’m getting this error:

    [Media Sync] [AJAX error] parsererror E: SyntaxError: Unexpected end of JSON input

    I enabled debug mode and can see the error happens always at item number 20. In the console I have this error:

    ajax_script.js?ver=1.2.3:74 [Media Sync] [Import] [AJAX error] parsererror SyntaxError: Unexpected end of JSON input
        at parse (<anonymous>)
        at load-scripts.php?c=1&load[chunk_0]=jquery-core,jquery-migrate,utils&ver=5.7:formatted:3751
        at l (load-scripts.php?c=1&load[chunk_0]=jquery-core,jquery-migrate,utils&ver=5.7:formatted:3763)
        at XMLHttpRequest.<anonymous> (load-scripts.php?c=1&load[chunk_0]=jquery-core,jquery-migrate,utils&ver=5.7:formatted:3900)
Viewing 15 replies - 1 through 15 (of 22 total)
  • Plugin Author erolsk8

    (@erolsk8)

    Hi @rafaviana, maybe the file name contains a special character that causes this error, for example, ” or ‘. I think I even handled those, but maybe this is something that I didn’t try.

    Could you try to pinpoint which file causes this and send me that file name?

    Thanks

    Erol

    Plugin Author erolsk8

    (@erolsk8)

    Also, you should be able to see more details in Network tab -> click on failed ajax_script.js -> Preview tab on the right.

    Thread Starter rafaviana

    (@rafaviana)

    HI @erolsk8 , thanks for the quick reply.
    I just tried to run on dry mode and it runs perfectly with no errors.
    So I decided to import a different folder and it’s importing everything so far, with no errors. Maybe on that folder there is an item with a special character as you said.

    After this import I will try to detect which file is causing the errora

    Thread Starter rafaviana

    (@rafaviana)

    Bad news, everything was going well but same error comes up.
    I checked ajax_script.js in Network Tab as you suggest but I can’t see nothing important…

    This is the code block browser console is mentioning:

    function outputError(errorMessage = null, error = null, isItemError = false) {
    				console.error("[Media Sync] [Import] " + errorMessage, (error ? error : ''));
    
    				if(!isItemError) {
    					var errors = "[Media Sync] " + errorMessage + (error ? "\nE:\n" + error : '');
    					// alert(errors);
    					plugin.find('.js-media-sync-error-placeholder').removeClass('hidden').html(errors);
    					setActiveStatus(false);
    				}
    			}
    • This reply was modified 3 years, 7 months ago by rafaviana.
    Plugin Author erolsk8

    (@erolsk8)

    Yes, that code is fine, it’s just trying to show what happened in the backend. But this part: “[AJAX error]” is telling me that the actual network request failed. So I’d try to find something in Network tab, or even better if you can debug the actual PHP backend ??

    Thread Starter rafaviana

    (@rafaviana)

    I’d love to know how to do it but I’m not a developer ??
    I’m running this on a fresh wordpress installation, don’t know if it’s important to share.
    Can it be a server limitation? I already increase WP memory limit and max_execution_time

    Plugin Author erolsk8

    (@erolsk8)

    It could be a server limitation or many other things that happen while this plugin tries to update the database. It’s hard to know what it is without seeing some backend (PHP) error. These errors you copied are all frontend (JS).

    Maybe if you could somehow get PHP error logs from your server.

    https://snapcreek.com/blog/wordpress/wordpress-error-log-friend/

    https://www.wpbeginner.com/wp-tutorials/how-to-set-up-wordpress-error-logs-in-wp-config/#:~:text=Reviewing%20Your%20WordPress%20Error%20Logs&text=Once%20connected%2C%20go%20to%20%2Fwp,and%20notices%20that%20were%20logged.

    Thread Starter rafaviana

    (@rafaviana)

    Error log is enabled but it doesn’t show on the folder after the error shows up. Since the errors all all from frontend, probably they don’t show in the error log because of that no?

    Plugin Author erolsk8

    (@erolsk8)

    Well, if it was a frontend issue, then yes, it wouldn’t be in .log file, just in the browser (console, etc.).

    But based on your first message, I’m guessing that error is in the backend (because of “[AJAX error]” part which happens when ajax_script.js network request fails). And that “Unexpected end of JSON input” part is because the backend doesn’t return a properly formatted response, because it fails with some error (which might be in Network tab or error logs) ??

    This just gave me an idea for another debug option for this plugin, which would just output (somewhere in UI) whatever happened in the backend. That would mean not having all of that “fancy” UI during import (counter, progress bar, marking rows as successfully imported, etc.), but it might help in these cases.

    I mean, it’s just an idea, not sure when or if I’ll have time to do it or if it will even work good ??

    Thread Starter rafaviana

    (@rafaviana)

    Let’s see if this helps, these are the errors I’m getting:
    https://tinyurl.com/yhvd9l4d
    https://tinyurl.com/yhhsplt3

    Plugin Author erolsk8

    (@erolsk8)

    Thread Starter rafaviana

    (@rafaviana)

    I can only see content in preview with the first 2 batches, the 3rd one doesn’t show anything: https://tinyurl.com/yf668xnz

    Plugin Author erolsk8

    (@erolsk8)

    Hmm that’s strange, maybe PHP debug is turned off or I don’t know. But that’s where the issue should be, that 3rd response should be similar to the first two. Maybe it’s something specific to files (or file names) in that batch.

    Thread Starter rafaviana

    (@rafaviana)

    The issue is related with the filenames, for example:
    – original filename: mobile_cat logo-1.jpg (name has a space)
    – name visible in the plugin: mobile_cat?logo-1.jpg

    it has this “?” character

    Plugin Author erolsk8

    (@erolsk8)

    Heh, interesting ??

    Spaces aren’t a problem here, but this is some unknown character. And your database probably doesn’t support saving it, so this import fails.

    This “?” character is actually a substitute / replacement character:
    https://en.wikipedia.org/wiki/Substitute_character
    https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character

    Thank you very much for sharing what you’ve found.

    Maybe I’ll somehow need to detect and replace those strange characters. Though I’m not sure how to get it in my file name now. If I just copy “mobile_cat logo-1.jpg” that’s just a normal space and import works.

Viewing 15 replies - 1 through 15 (of 22 total)
  • The topic ‘JSON error: not working’ is closed to new replies.