• Resolved 1234s282

    (@1234s282)


    Hello

    Attempting to integrate a booking widget into a clients website. Site is running the latest WordPress 5.2.2 with HTTPS.

    I apologise for being a bit “vague” in this topic however due to client confidentiality I cannot disclose the URL or name of the website in question. Hopefully someone can still point me in the right direction!

    The company that handles this booking widget provides two lots of code for integration into your own website. The first is an external JavaScript file that has to go in either header.php or footer.php , then the second lot of code is specific to the particular event you want the booking widget for.

    I have put the following into a static basic HTML page and it works without an issue.

    <html>
    <head>
    <title>Test Page</title>
    <script type="text/javascript" src="<External JS File>"></script>
    </head>
    <body>
    <a rel="widget" target="_top" style="display: block; margin: 25px auto; text-align: center" href="<LINK TO EVENT>"></a>
    </body>
    </html>

    I have added the external JavaScript to header.php, footer.php and also in-line on the same page and I can see that it is being correctly loaded using Google Chromes Developer Tools, however I just get a blank space where the second lot of code is entered on the page.

    This is on a “blank” WordPress 5.2.2 installation, tried both HTTP and HTTPS (all my clients sites are HTTPS) , using the stock Twenty Nineteen theme (I also tried Twenty Sixteen , no difference). No plugins or caching etc. are in use on the development site I am testing this with.

    Does anybody have any advice? I have also tried 3rd party plugins such as “Insert Headers & Footers” to handle the insertion of the JavaScript code however this didn’t make a difference.

    I look forward to hearing any advice and suggestions!

Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter 1234s282

    (@1234s282)

    Quick update – after noticing my web host allows multiple WordPress version installs via Softaculous I have done some more research:-

    WordPress 4.9.10 – Works
    WordPress 5.0.4 – Works
    WordPress 5.1.1 – Doesn’t Work
    WordPress 5.2.2 – Doesn’t Work

    So something happened in the 5.1 update to change the way JavaScript works? Can anybody elaborate?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Do you absolutely need to provide a link to that JS, or can you grab the code from that JS file?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    It’s important that you tell us exactly what the output is when you say “I just get a blank space where the second lot of code is entered on the page”

    And detail what code you’re adding and where exactly in which file.

    Thread Starter 1234s282

    (@1234s282)

    Hi Andrew

    I appreciate such a prompt reply – I have tried linking to the file externally and just typing the contents of the JS file straight in. Neither worked.

    Following the booking companies provided instructions they state to add the

    <script type=”text/javascript” src=”<External JS File>”></script>

    to either the header.php or footer.php towards the bottom.

    Whichever one I choose (or if i just put this in the same page as where I want the content to go) , I can see that it’s being requested and successfully loaded.

    I still get a blank space on the page wherever I enter the second lot of code instead of the booking widget loading – the full code still appears though in the page source – just nothing renders :

    “>

    While on my static HTML page with the exact same code it loads up the booking widget properly.

    As amended to my earlier post – I just did some test installations of WordPress 4.9.10 and 5.0.4 – both of those displayed the booking widget properly so it seems like something was edited in the newer WordPress releases (possible for security?)

    Thread Starter 1234s282

    (@1234s282)

    I also found some very basic Javascript code online as an example (not related at all to this booking site) and that Javascript worked – so it isn’t like WordPress is blocking scripts or anything like that.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Would you be able to provide the full code you’re entering when you say:

    
    <script type=”text/javascript” src=”<External JS File>”></script>
    

    If the External JS File is on the Web then it won’t be sensitive and you should feel free to post it here.

    • This reply was modified 4 years, 9 months ago by Andrew Nevins.
    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    I want to get into the full detail of where exactly you’ve added it to the header.php file and footer.php file.

    Thread Starter 1234s282

    (@1234s282)

    <script type="text/javascript" src="https://www.stickytickets.com.au/static/widgets/v1/buy-tickets-1.0.2.js"></script>

    Thanks Andrew

    Thread Starter 1234s282

    (@1234s282)

    Following this integration guide to the letter

    https://stickytickets.freshdesk.com/support/solutions/articles/3000017890-ticket-widget

    Even their support people aren’t sure – said they’d get back to me so I decided to post on here.

    Appreciate all your replies 🙂

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    By briefly looking at that JS code, I can see that there are already some requirements that it needs before it can run.

    Now I’m questioning where the code exactly fails. As you haven’t been able to provide a link to your site, what you need to do is create a jsFiddle file that replicates your issue. You can copy the source code of your website and put it into the HTML part of the jsFiddle demo.

    Alternatively you can try debugging JS yourself: https://developers.google.com/web/tools/chrome-devtools/javascript/

    Thread Starter 1234s282

    (@1234s282)

    Thanks Andrew – this is a whole new area to me but I shall have a look 🙂

    @anevins wordpress wont allow me to add script codes from my ad companies in my widgets or posts where i want adds to appear.

    when placed in widgets, it will spin for eternity without saving.
    when placed in posts where i want ads to appear, it will generate page not found.

    wordpress wont allow javascript.

    i need help

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Which ad companies, is it just Google? There are plugins available for Google adverts so to help you on this.

    Thread Starter 1234s282

    (@1234s282)

    Just to update you, the ticket company fixed something at their end (I don’t know the details) and now it works!

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘External Javascript Not Working?’ is closed to new replies.