Loading a CSV file using jQuery GET returns the header but no data

advertisements

When reading a CSV file from a server using the jQuery 'GET' function I do not get any data. When I look at the code using FireBug I can see the GET request is sent and the return value is '200 OK'. Also I see that the header is returned correctly so the request is definitely made, and data is returned. This is also what I see in Wireshark. Here I see the complete contents of the CSV file is returned as a standard HTTP response.
But the actual data is not there in my script. Firebug shows an empty response and the 'success' function is never called. What could be wrong ?

EDIT: An essential part of information appeared to be missing from my question. The following code runs on my local machine and is started by Aptana Studio in Firefox using the built-in test server.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>New Web Project</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script src="jquery.js" type="text/javascript" charset="utf-8"></script>

       <script type="text/javascript">
        var csvData;
        $(document).ready(function() {
           $("#btnGET").click(function() {
                csvData = $.ajax({
                    type: "GET",
                    url: "http://www.mywebsite.com/data/sample_file.csv",
                    dataType: "text/csv",
                    success: function () {
                       alert("done!"+ csvData.getAllResponseHeaders())
                     }
                });
           });
        })
 </script>
 </head>   

     <body>
        <h1>New Web Project Page</h1>
        <button id="btnGET">GET Data</button>
    </body>
</html>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>New Web Project</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script src="jquery.js" type="text/javascript" charset="utf-8"></script>

       <script type="text/javascript">
        var csvData;
        $(document).ready(function() {
           $("#btnGET").click(function() {
                csvData = $.ajax({
                    type: "GET",
                    url: "http://www.mywebsite.com/data/sample_file.csv",
                    dataType: "text/csv",
                    success: function (result) {
                       alert(result);
                       alert("done!"+ csvData.getAllResponseHeaders())
                     }
                });
           });
        })
 </script>
 </head>   

     <body>
        <h1>New Web Project Page</h1>
        <button id="btnGET">GET Data</button>
    </body>
</html>