0

I have 2 files named index.html and mytext.txt in the same folder. I want to get contents of mytext.txt using an ajax call in the index.html. I use this code but it is only working in firefox not chrome:

$.ajax({
    url: "mytext.txt",
    dataType: 'text',
    success: function(data) {
        alert(data);
    }
});

I am opening index.html simply from explorer not server!

user1447420
  • 1,153
  • 2
  • 10
  • 14

2 Answers2

0

I think you'll have to start a webserver for this to work in chrome due to cross origin policy

DimitrisBor
  • 277
  • 3
  • 12
0

Refer

Link 1

Link2

var file = Components.classes["@mozilla.org/file/local;1"].
   createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("/home");
Community
  • 1
  • 1
Neeraj Dubey
  • 4,193
  • 7
  • 25
  • 47