4

I'm using IE8 with jQuery 1.9.1. I want the user to select a csv file. The contents of the file should be displayed in the alert. So far, I have been able to do this:

function getCsv(filepath) {
    $.ajax({
        type: "GET",
        url: filepath,
        dataType: "text",
        success: function(data) {
            alert(data);
        },
        error: function(xhr, ajaxOptions, thrownError) {
            alert("Status: " + xhr.status + "     Error: " + thrownError);
        }
    });
};

$("#upload").click(function() {
    var fname = $("#filename").val();
    fname = fname.replace(/\\/g, "/");
    fname = "file:///" + fname;
    getCsv(fname);
});

This works great when I open the html file directly(by double clicking the file). But when I deploy this on a server(IIS Server) it gives the error alert.

Also i have used jQuery.support.cors = true to avoid problems with CORS.

1 Answers1

1

See either:

Evan Plaice
  • 13,944
  • 6
  • 76
  • 94
iheggie
  • 2,011
  • 23
  • 23