I’m trying to download a CSV file to populate a graph with jQuery. Everything works fine in Firefox (12.0 win) but fails in IE (9.0 win) and Chrome (19.0 win.
The error thrown is just “error”. Nothing more.
I suspect it is due to a combination of mime-types and jQuery dataType
but I just can’t get it working. Does anyone have any suggestions?
My response from the server is this: (copied from Firefox)
Cache-Control: private, s-maxage=0
Content-Disposition: attachment;filename=data.csv
Content-Type: text/plain
Date: Mon, 21 May 2012 12:53:36 GMT
Server: Microsoft-IIS/7.5
Transfer-Encoding: chunked
X-AspNet-Version: 4.0.30319
X-AspNetMvc-Version: 3.0
X-Powered-By: ASP.NET
My jQuery snippet:
$.ajax({
url: 'dummyurl',
type: 'GET',
dataType: 'text',
success: function (data) {
// process
},
error: function(jqXHR, textStatus, errorThrown){
alert('An error occurred: ' + textStatus + ', ' + errorThrown);
}
});
(Yes, I have googled and tried a lot of suggestions 🙂 )
I’ve finally found the solution. Here it is if someone googles for it:
Content-Type MUST include
charset. If not, the request will just die with no further information in chrome.