Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • nyadna
    Participant

    Hi there,

    I’m pasting HTML code that contains Javascript in the shortcoder.

    It’s a snippet from Mailchimp to embed a sign up form on my blog. I get a 500 internal server error when I try to save my shortcode with the original code. I realised that when I remove the javascript <script> tags, I can update the shortcode and it works fine. That Javascript snippet is the validation of the form fields basically. This is it:

    <script type=’text/javascript’ src=’//s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js’></script><script type=’text/javascript’>(function($) {window.fnames = new Array(); window.ftypes = new Array();fnames[1]=’MMERGE1′;ftypes[1]=’text’;fnames[0]=’EMAIL’;ftypes[0]=’email’;}(jQuery));var $mcj = jQuery.noConflict(true);</script>

    Any ideas on how I can make this HTML + Javascript work? Is this a bug?

    Thanks.

    Hi @nyadna,

    Usually 500 internal server error occurs when the server is overloaded.

    When you were publishing the shortcode it is possible that the server was overloaded at that time. Publishing a shortcode is same as publishing a normal post. So the crash can happen even when you publish a post.

    I tried the same code at my end and there were no crashes.
    Please do try again.

    You might have also have to consider the recommendations in below page like increasing the PHP memory limit if the issue reoccurs.

    https://www.wpbeginner.com/wp-tutorials/how-to-fix-the-internal-server-error-in-wordpress/

    Thanks,
    Aakash

    nyadna
    Participant

    Hi Aakash,

    Thank you for the speedy answer! I don’t think it’s an issue that has to do with server overload or PHP memory. I made a quick video to show you what happens. Any help is appreciated.

    https://www.screencast.com/t/vWDJLowFwM

    Thank you!

    Hi @nyadna,

    That is strange. Only with debugging enabled I can find out the eact issue. I’m not able to see the issue on my side.

    One thing I notice is that the single quote is a special character.
    Not sure if wordpress/or any plugin is catching it as a security threat.

    Please use the code below where the script has the normal single quote.

    <script type='text/javascript' src='//s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js'></script><script type='text/javascript'>(function($) {window.fnames = new Array(); window.ftypes = new Array();fnames[1]='MMERGE1';ftypes[1]='text';fnames[0]='EMAIL';ftypes[0]='email';}(jQuery));var $mcj = jQuery.noConflict(true);</script>

    Thanks,
    Aakash

    nyadna
    Participant

    Hi Aakash,

    Amazing! That worked! I was sure it was something within the code that bothered WordPress or the plugin but I didn’t know what exactly as I’m not a coder :s. Great observation skills! I really appreciate your help. You deserve a cup of coffee 😉

    All the best,

    Stefania

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Subscribe for updates

Get updates on the WordPress plugins, tips and tricks to enhance your WordPress experience. No spam. View newsletter