0

I have this small Ajax function that is suppose to grab an online CSV file but it keeps failing with this error:

NS_ERROR_FAILURE:
    request.send();                  csonv.js (line 101)

The function in question looks like this:

 var ajax = function(url) {
        request = new(window.ActiveXObject || XMLHttpRequest)("Microsoft.XMLHTTP");
        request.open("GET", url, 0);
        request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        request.send();
        return request.responseText;

I am attempting to use csonv.js to grab a CSV file from the internet and convert it to JSON. Any help is appreciated. Thanks.

  • Does the web server you're contacting have a MIME type entry for .csv files? Can you download the file by typing its URL in a browser? – Rodney G Oct 30 '14 at 13:58
  • Is the URL in your domain? – Barmar Oct 30 '14 at 14:01
  • I am able to download the file in my browser. It is a public file on a public website. I also have a Java function that successfully attains it using `URL,` `URLConnection,` `InputStreamReader,` and `BufferedReader.` – BarryDale2014 Oct 30 '14 at 14:06
  • I see a bunch of issues here, although I'm not sure if they would cause your problem. 1. You are using the xmlhttp object if it's available. You should reverse this and only use it if xmlhttprequest is not available. 2. Why are you not doing this asynchronously? 3. Why are you setting content-type to x-www-form-urlencoded when you aren't posting data to a form? – scott.korin Oct 30 '14 at 14:09
  • http://stackoverflow.com/questions/17874730/how-to-make-cross-domain-request – scott.korin Oct 30 '14 at 14:12

0 Answers0