Cross domain XMLHttpRequest
Tag : php , By : socurious
Date : March 29 2020, 07:55 AM
hop of those help? You can't. XHR is subject to the same origin policy. There is ongoing work to design and implement systems to allow cross-domain XHR, but the current state of those (the lack of browser support in particular) make it impractical for any real project.
|
XmlHttpRequest cross-domain
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Because cause security, all browser are not accept a ajax cross-origin request from your site. In order to browser accept a ajax cross-origin request, server code must set header "Access-Control-Allow-Origin" to response to notify browser that it accept a ajax cross-origin request.
|
XMLHttpRequest cross domain
Date : March 29 2020, 07:55 AM
like below fixes the issue If Access-Control-Allow-Origin header is set in response headers of datafile.php it works :)
|
Chrome - Cross Origin XMLHttpRequest doesnt seem to work in contentscript
Date : March 29 2020, 07:55 AM
Does that help AFAIK only internal extension scripts that are executed in the privileged context like the background page script (not content scripts which don't have access to privileged APIs) can make Cross-Origin XMLHttpRequest (more info in the official docs). Invoke XHR in your background page script, send a message to the tab's content script. chrome.webRequest.onHeadersReceived.addListener(function(details){
if(isPDF(details))
{
var xhr = new XMLHttpRequest();
var tabId = details.tabId; // save id in the local context
xhr.onload = function() {
chrome.tabs.sendMessage(tabId, {imgData: this.responseText});
};
xhr.open("GET", "http://localhost:81/getImage.php", true);
xhr.send();
chrome.tabs.executeScript(details.tabId, {file: "content.js", ..............
..................
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
if (message.imgData) {
document.body.innerHTML = "";
var img = document.createElement("img");
img.src = "data:image/jpeg;base64," + message.imgData;
document.body.appendChild(img);
}
});
|
cross domain XMLHttprequest
Date : March 29 2020, 07:55 AM
|