i am trying to alert a JSON element using JQuery , here is my code:
data.js JSON data
[
{
"name": "bader",
"major": "medicine",
"id": "334453"
}
]
Jquery code
$(document).ready(function() {
$.getJSON("data.js", function(json) {
alert("JSON Data: " + json.name);
});
});
i tried to inspect element i had this error on my consol
XMLHttpRequest cannot load file:///data.js. Origin null is not allowed by Access-Control-Allow-Origin.
i am still very new to handling JSON and JQUERY , i do not know where i went wrong here , if someone could help