user3326265
user3326265

Reputation: 257

Ajax is not working in chrome

I made an ajax call to get datas from the excel. All working fine, but in chrome i got the below error

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin null is therefore not allowed access.

My AJAX

$(function () {

        $.ajax({
        type: "GET",
        url: "Data.csv",--------> (excel file)
        dataType: "text",
        success: function(data) {

        processData(data);

}

My excel file is in the same location where the html file is saved. it works fine in ie and firefox browser, but i am getting error in chrome. Searched for the solution, some guys suggested CORS request.But i dont know how to use that. Can any one tell me how to overcome this error using CORS with example

Thanks in advance

Upvotes: 0

Views: 287

Answers (1)

Arvind
Arvind

Reputation: 671

If the html file & csv file are in the same folder, I don't think so its a CORS issue. Are you by any chance loading the page using file://somedir/somedir/index.html ? This will for sure not work.

If you are loading the page via say http:// localhost:1234/somedir/index.html and you are still having this issue, I have put together a post for CORS here. This is a wrapper for Cross Browser Cross Domain Ajax.

Do let me know if this helps!

Upvotes: 1

Related Questions