javascriptgoogle-app-enginegoo.gl

old topic title about jquery


The goal is to automate a users workflow, by scraping the current webpage, preparing a structure and returning it in a format with a shortened URL.

The contributions from the stackoverflow community contributed an effective solution needed.


Solution

  • From what I'm reading in the documentation of https://api.jquery.com/jquery.getscript/ the error seems legit.

    The callback is fired once the script has been loaded but not necessarily executed.

    You should have a look at the documentation regarding proper integration of the javascript library presented across these following links

    dev jscript, samples

    However I think you could fix your problem by loading the library and providing a callback function reference which will be executed once the library has been loaded and executed.

    I think that what you should do is wrap the bits requiring a gapi instance in a callback function, say gapiIsLoaded like so

    function gapiIsLoaded() {        
    
        gapi.client.setApiKey("<API_KEY_HERE>");
        gapi....
    }
    

    ..and point the getScript function to this URL instead

    https://apis.google.com/js/client.js?onload=gapiIsLoaded