1

Regarding this error [in image], I surfed the internet and applied all the techiniques such as Error in Chrome only: XMLHttpRequest cannot load file URL No 'Access-Control-Allow-Origin' header is present on the requested resource, still, it is not working in my local. Am just trying to get the JSON file from system local [D:/somefolder]. Any help? please

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="application/json; charset=UTF-8"/>
</head>
<body>
<div id="serverReply"><b><a href="#"  onclick="getMessage();">Get message</a></b></div>
<script type="text/javascript">
function getMessage()
{
  if (window.XMLHttpRequest)
  {

      xmlhttp=new XMLHttpRequest();

  }else
  {

    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

    xmlhttp.onreadystatechange=function()
  {
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {

        document.getElementById("serverReply").innerHTML=xmlhttp.responseText;

    }
  }
    xmlhttp.open("GET","carousel-data.json",true);
    xmlhttp.send();
}
</script>
</body>
</html>

Error that I am getting now

Community
  • 1
  • 1
Sakthivel
  • 678
  • 2
  • 6
  • 19

0 Answers0