• Resolved neefje

    (@neefje)


    Hi, my slider suddenly doesn’t load anymore. I get this error:

    Uncaught SyntaxError: Unexpected token ILLEGAL

    In this line:

    var timer_ml_slider_1676723125 = function() {
            <strong>if (window.jQuery && jQuery.isReady) {</strong>
    Uncaught SyntaxError: Unexpected token ILLEGAL
                ml_slider_1676723125(window.jQuery);
            } else {
                window.setTimeout(timer_ml_slider_1676723125, 100);
            }
        };

    Has to be something with &. Do you know a fix?

    https://www.ads-software.com/extend/plugins/ml-slider/

Viewing 8 replies - 1 through 8 (of 8 total)
  • matchalabs

    (@matchalabs)

    Could you send me a link to your site please? And also let me know which browser you’re using.

    Thanks
    Tom.

    Thread Starter neefje

    (@neefje)

    Hi Tom,

    https://www.jenasound.nl

    Google Chrome, also tested latest Internet Explorer

    matchalabs

    (@matchalabs)

    Thanks,

    The source says:

    if (window.jQuery &# 038;& jQuery.isReady) {

    The bit that says ‘&# 038;’ should just say ‘&’. WordPress is converting it for some reason.

    I found a few support threads about this on google: https://www.ads-software.com/support/topic/unwanted-characters-038, but none of them seem to come up with a real solution.

    Have you edited anything that you think might have caused it? Has it just started happening recently?

    Regards,
    Tom.

    Thread Starter neefje

    (@neefje)

    Hi Tom,

    Thanks. I haven’t edited anything. Updated some plugins today, but removed them to test if any of them were causing the problem.

    Only the first & is converted, not the second. Really strange. It just started tonight …

    matchalabs

    (@matchalabs)

    Yeah, it is strange! Not seen it before.

    The ‘quick but not quite right’ solution seems to be to add this line to your /wp-content/themes/[your theme]/functions.php file:

    remove_filter('the_content', 'wptexturize');

    Hopefully that should get you up and running while I work out something better..

    Regards
    Tom.

    matchalabs

    (@matchalabs)

    Hi,

    This is fixed locally now, it will be available in v1.3.

    The fix was to change the code to:

    if (window.jQuery) {
        if (jQuery.isReady) {
            [snip]
        }
    }

    Not ideal, but a workaround for the “&” bug.

    Regards,
    Tom.

    Thread Starter neefje

    (@neefje)

    Hi Tom,

    Thanks for the fix. Got it to work again:

    /**
         * Return the Javascript to kick off the slider. Code is wrapped in a timer
         * to allow for themes that load jQuery at the bottom of the page.
         *
         * @return string javascript
         */
        private function get_inline_javascript($type, $identifier) {
            $retVal  = "\n<script type='text/javascript'>";
            $retVal .= "\n    var " . $identifier . " = function($) {";
            $retVal .= "\n        $('#" . $identifier . "')." . $type . "({ ";
            $retVal .= "\n            " . $this->get_params();
            $retVal .= "\n        });";
            $retVal .= "\n    };";
            $retVal .= "\n    var timer_" . $identifier . " = function() {";
            $retVal .= "\n        if (window.jQuery) {";
            $retVal .= "\n        if (jQuery.isReady) {";
            $retVal .= "\n            " . $identifier . "(window.jQuery);";
            $retVal .= "\n        } else {";
            $retVal .= "\n            window.setTimeout(timer_" . $identifier . ", 100);";
            $retVal .= "\n               }";
            $retVal .= "\n            };";
            $retVal .= "\n        }";
            $retVal .= "\n    timer_" . $identifier . "();";
            $retVal .= "\n</script>";
    
            return $retVal;
        }
    matchalabs

    (@matchalabs)

    Hi Neefje,

    Just wanted to let you know that we actually backed out this fix from 1.3 – so it won’t be included. It seems like an isolated case, but if we get more reports in we’ll put the fix back in.

    If you update to 1.3, you can put your fix into /ml-slider/inc/metaslider.class.php

    Regards,
    Tom

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘& in javascript’ is closed to new replies.