1
 $.getJSON('test1.json', function(data) 
  {
  for (i in data.conferences) {
  var item = data.conferences[i];
  array1.push({
  cid:item.id,
  confName: item.cname,
  confStart:item.start
  }); }
});

I use the function for getting values from java to jquery. In chrome and opera shows same error, but it works on IE and mozilla.
Give me a solution for that please.

XMLHttpRequest cannot load file:///C:/Users/winnova1/Desktop/tree/conferences/test1.json. Origin null is not allowed by Access-Control-Allow-Origin.
Uncaught TypeError: Cannot read property 'conferences' of null

1 Answer 1

1

For security reasons, on Chrome and Opera you cannot use XMLHttpRequest to load local files.
You must run it on a web server, even if that web server is running on localhost.

Sign up to request clarification or add additional context in comments.

2 Comments

Sir,I tried using my eclipse server also.I load the file into my eclipse and then add the url to function like this win-pc:2013/Conference/test1.json
@AvinashThadavarthi: You must load the HTML as well as the JSON from the same web server and you must continue to omit the http:// in the string passed to getJSON.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.