Trying to load an API and a JS file dynamically

后端 未结 3 1878
梦如初夏
梦如初夏 2021-02-09 02:43

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 tri

3条回答
  •  时光取名叫无心
    2021-02-09 02:59

    In the skyrunner.js file they are using document.write to make the page blank on load call back... So here are some consequences in your scenario..

    1. This is making page blank when you click on button.
    2. So, it removes everything from page even 'jQuery.js' that is why call back is not working.. i.e main function is cannot be invoked as this is written using jQuery.
    3. And you have missed a target 'div' tag with id = map(according to the code). Actually this is the target where map loads.
    4. Another thing i have observed is maps is not actually a div in current context, that is maps api to load.

    Here you must go with the Old school approach, That is.. You should include your skyrunner.js file at the top of the head content.

    So try downloading that file and include in head tag.

    Thanks

提交回复
热议问题