Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6938109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:27:02+00:00 2026-05-27T12:27:02+00:00

I am trying to load Skyscanner API dynamically but it doesn’t seem to work.

  • 0

I am trying to load Skyscanner API dynamically but it doesn’t seem to work. I tried every possible way I could think of and all it happens the content disappears.

I tried console.log which gives no results; I tried elements from chrome’s developers tools and while all the content’s css remains the same, still the content disappears (I thought it could be adding display:none on the html/body sort of). I tried all Google’s asynch tricks, yet again blank page. I tried all js plugins for async loading with still the same results.

Skyscanner’s API documentation is poor and while they offer a callback it doesn’t work the way google’s API’s callback do.

Example: http://jsfiddle.net/7TWYC/

Example with loading API in head section: http://jsfiddle.net/s2HkR/

So how can I load the api on button click or async? Without the file being in the HEAD section. If there is a way to prevent the document.write to make the page blank or any other way. I wouldn’t mind using plain js, jQuery or PHP.

EDIT:

I’ve set a bounty to 250 ontop of the 50 I had previously.

Orlando Leite answered a really close idea on how to make this asynch api load although some features doesn’t work such as selecting dates and I am not able to set styling.

I am looking for an answer of which I will be able to use all the features so that it works as it would work if it was loading on load.

Here is the updated fiddle by Orlando: http://jsfiddle.net/cxysA/12/

–

EDIT 2 ON Gijs ANSWER:

Gijs mentioned two links onto overwriting document.write. That sounds an awesome idea but I think it is not possible to accomplish what I am trying.

I used John’s Resig way to prevent document.write of which can be found here: http://ejohn.org/blog/xhtml-documentwrite-and-adsense/

When I used this method, I load the API successfuly but the snippets.js file is not loading at all.

Fiddle: http://jsfiddle.net/9HX7N/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:27:02+00:00Added an answer on May 27, 2026 at 12:27 pm

    For problematic cases like this, you can just overwrite document.write. Hacky as hell, but it works and you get to decide where all the content goes. See eg. this blogpost by John Resig. This ignores IE, but with a bit of work the trick works in IE as well, see eg. this blogpost.

    So, I’d suggest overwriting document.write with your own function, batch up the output where necessary, and put it where you like (eg. in a div at the bottom of your <body>‘). That should prevent the script from nuking your page’s content.

    Edit: OK, so I had/took some time to look into this script. For future reference, use something like http://jsbeautifier.org/ to investigate third-party scripts. Much easier to read that way. Fortunately, there is barely any obfuscation/minification at all, and so you have a supplement for their API documentation (which I was unable to find, by the way — I only found ‘code wizards’, which I had no interest in).

    Here’s an almost-working example: http://jsfiddle.net/a8q2s/1/

    Here’s the steps I took:

    1. override document.write. This needs to happen before you load the initial script. Your replacement function should append their string of code into the DOM. Don’t call the old document.write, that’ll just get you errors and won’t do what you want anyway. In this case you’re lucky because all the content is in a single document.write call (check the source of the initial script). If this weren’t the case, you’d have to batch everything up until the HTML they’d given you was valid and/or you were sure there was nothing else coming.
    2. load the initial script on the button click with jQuery’s $.getScript or equivalent. Pass a callback function (I used a named function reference for clarity, but you can inline it if you prefer).
    3. Tell Skyscanner to load the module.

    Edit #2: Hah, they have an API (skyscanner.loadAndWait) for getting a callback once their script has loaded. Using that works:

    http://jsfiddle.net/a8q2s/3/

    (note: this still seems to use a timeout loop internally)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to load fragments of XHTML markup using jQuery's $.fn.load function, but it
i am trying load file after it created from /stext command line but its
I'm trying load a 3rd party DLL but I get an error when attempting
Trying to load a page fragment, or at least jump to a div but
I trying to load feeds from my blog but this is resulting in the
i am trying to load r1,r2,r3 column to a checkboxlist, but the output is
So I'm trying to load some returned html from an .aspx page but a
I'm trying load pg_trgm module to PostgreSQL, but something going wrong: $ psql -d
Trying to load a file into python. It's a very big file (1.5Gb), but
Im trying to load a css file for ipad only. I tried this: <link

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.