Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Scripts in queue

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #42805
    cparliaros
    Member

    When the page is ready I have a function which runs first and get data from a google spreadsheet and using them to create content of the main container in the html. Then the rest of the script follows which depends on the content that is created from the previous function. For example there is an array which should get as values the elements that have been created before.

    The first function take few seconds because there a lot of data and as I did some debugging, it seems that while the content is still loading the script has been moved on and the array seems empty.

    Both parts of the script have been tested and work fine separate one from each other.

    I am using .getJSON() if that helps, in order to get the data.

    What can I do for that?

    I fixed it with a second callback

    #125130
    mweldan
    Member

    i will check for specified element to be ready first before use it for anything.

    $(‘.element1’).ready(function(){ //something });
    $(‘.element2’).ready(function(){ //something else });

    or if that element require dynamically changes..

    maybe can check for its content before do anything..

    $(‘.dynamic_element’).length

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.