[Solved] javascript running befor jquery in chrome extension [closed]


Good news everyone, you can call suggest asynchronously!

if (/^https?:\/\/ieeexplore\.ieee\.org.*/.test(downloadItem.referrer)) 
{   
  /* ... */
  $.get(u, function(data) 
  {
    //parse webpage here
    //set the value of name here
    suggest({filename: result}); // Called asynchronously
  });
  return true; // Indicate that we will call suggest() later
}

The key point here: chrome.downloads.onDeterminingFilename handler will exit before your $.get callback gets executed. Chrome will not, by default, wait for your suggestion in this case – but you can indicate “I will tell you later, please wait” by returning true. This is all written in the docs.

Please do read some tutorials on async functions. For example, this answer.

solved javascript running befor jquery in chrome extension [closed]