Accessing data.json file using ajax calls receiving error as
Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
I am using a local json file, not server data.
I have tried with start chrome --allow-file-access-from-files
is is working fine but everytime i need to run these command
How to add metatag for allow-file-access-from-files
for particular file when code runs in chrome/jquery
Ajax call :
$.ajax({
url: 'data.json',
dataType: 'JSONP',
jsonpCallback: 'callbackFnc',
type: 'GET',
async: false,
crossDomain: true,
success: function (data) {
engines = data;
myDOM();
},
failure: function () { },
complete: function (data) {
if (data.readyState == '4' && data.status == '200') {
console.log(" Status: 'SUCCESS' ");
}
else {
console.log(" Status: 'FAIL' ");
}
}
});
data.json :
[
{
"Function": "CAB",
"Part_No": "RE284091",
"Description": "Cab Air Filter",
"Hours": "1000",
"Model": "7200R",
"Serial_NO":"xxxx"
},
{
"Function": "CAB",
"Part_No": "RE291412",
"Description": "RECIRCULATION AIR FILTER",
"Hours": "1000",
"Model": "7200R",
"Serial_NO":"xxxx"
}
]