Edit: Not duplicate, as my problem fails on every browser as mentioned; Edge, Chrome, FF etc.
I have a html file which will be on the person's machine, rather than on an http protocol. Note: it is important that it will be an html file on the person's machine.
Within the javascript is:
var dataARR = {
mydata: "No Data"
};
var dataJSON = JSON.stringify(dataARR);
$.support.cors = true;
$.ajax({
type: "POST",
url: "http://www.mywebsite.com/exclude.php",
async: true,
cache: false,
contentType: "application/json; charset=utf-8",
crossDomain: true, // This needs to be true for other people
data: { myJson: dataJSON },
success: function (data) {
var json = eval('(' + data + ')');
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
// Silent error
var zz = 2;
}
});
The file on my server http://www.mywebsite.com/exclude.php
is basic for testing.
exclude.php
header("Access-Control-Allow-Origin: *"); // To allow cross domain
$arr = ["181K2", "4V419"];
echo json_encode($arr);
This does not work if the html file on the person's local machine is launched from Edge, Chrome etc.
Edge gives the error XMLHttpRequest: Network Error 0x80070005, Access is denied.
.
Chrome gives the error XMLHttpRequest cannot load http://www.mywebsite.com/exclude.php. Request header field Content-Type is not allowed by Access-Control-Allow-Headers in preflight response.
Firefox: I am not sure how to find the FF error as I do not debug in FF generally and am unused to the system. However, when I put the breakpoints in I end up in the section error: function (XMLHttpRequest, textStatus, errorThrown) {