1

Any idea why the following Ajax call fails in Chrome, but not Firefox?

$.ajax({
    type: "GET",
    contentType: "text/csv; charset=utf-8",
    dataType: "text",
    cache: false,                    
    url: "http://127.0.0.1:8080/param1/param2?param3=csv&otherParams=type1,type2,type3"
 })
    .done(function(data) {
        console.debug("Data received from ajax call: " + data);
    })
    .fail(function(jqXHR, textStatus, errorThrown) {
         console.error("Data request failed (" + textStatus + "): " + errorThrown);
         console.debug(jqXHR.responseText);
    });

The URL that I am calling should return the data in csv format. I'm using jQuery 1.8.2. This works in Firefox, but not Chrome for some reason. The error message that I print out is:

Data request failed (text/csv): text/csv 

Interestingly, in Chrome I can see the data returned in the jqXHR.responseText, so I can't figure out why it's throwing an error. I assume it has something to do with my not specifying the csv format properly, but I thought setting the dataType or contentType would fix that. What am I missing?

I realize this is a common problem, but in spite of my Googling and searching around Stack Overflow, I have been unable to find a solution that fixes this problem for me. All the suggestions I've found have said to set the contentType, the dataType, or the cache to false. As you can see, none of these solutions has worked for me. Your help is greatly appreciated!

Steph
  • 2,135
  • 6
  • 31
  • 44

0 Answers0