'Chrome extension - response of ajax(settings).done won't display in popup
Am trying to display the response data of ajax(settings).done in the popup.html of my Chrome extension. But it is not working. It displays in console.log though.
manifest.json
{
"name": "Malware Detector",
"version": "0.0.1",
"manifest_version": 2,
"browser_action": {
"default_popup": "popup.html"
},
"permissions": [
"tabs"
]
}
popup.html
<body>
<div id="resultsDisplay"></div>
<script src="cloudmersive-validate-client.js"></script>
<script src="jquery-3.6.0.min.js"></script>
<script src="script.js"></script>
</body>
script.js
chrome.tabs.query({
active: true,
lastFocusedWindow: true
}, function(tabs) {
var tab = tabs[0];
// api
var settings = {
"url": "https://api.cloudmersive.com/virus/scan/website",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/x-www-form-urlencoded",
"Apikey": "my_key_here"
},
"data": {
"Url": tab.url
}
};
$.ajax(settings).done(function (response) {
console.log(response);
$("#resultsDisplay").html(response);
});
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
