I am using some AJAX calls in my popup on a but开发者_运维问答ton click:
var xhr = new XMLHttpRequest();
xhr.open("GET", yourURL, true);
xhr.send();
chrome.tabs.create({url:<some url here>});
The problem is that the popup closes as soon as the button is clicked, and I think thats why the ajax calls are not completing.
Is this a common issue? What can I do to make sure that the ajax calls have sufficient time to complete?
This is what a background page was made for. Move your code to a background page into some myFunction(), then call it from a popup: 
chrome.extension.getBackgroundPage().myFunction()
You need a callback after the request has finished.
var xhr = new XMLHttpRequest();
xhr.open("GET", yourURL, true);
xhr.onreadystatechange = function() {
    if (xhr.readyState===4 && xhr.status===200) {
        chrome.tabs.create({url:<some url here>});    
    }
}
xhr.send();
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论