0

I tried reading a local text file with Javascript(JQuery). With the following code.

$.ajax({
    type: 'GET',
    url: 'file:///C:/Users/kola/Desktop/b/data_file_text',
    error: function(e)
    {
        console.log(e);
    },
    success: function(e)
    {
        console.log(e.responseText);
    }
});

At the end of the execution, Error Method was triggered. Accessing the argument(e) returned. I Got the following Jquery Object.

readyState: 4
responseText: "My Expected Data"
status: 200
statusText: "OK"
....

Why will it triggered error and everything seems OK. Am I missing something? Thank you.

  • Possible duplicate of [Using AJAX to read local files](http://stackoverflow.com/questions/6923707/using-ajax-to-read-local-files) – Mikey Sep 22 '16 at 12:51
  • I understand that. Try running the code, if I got error because of Security Concern, how came I can still access the file's data from error method? – Taiwo Kolawole Sep 22 '16 at 12:55

0 Answers0