DragonWar% 2016-03-15 08:37 采纳率: 0%
浏览 916

使用$ .ajax()读取csv文件

Im having issues with reading a csv file using jquery ajax.I have two csv files with the same content.we are using the below code to get the data from the csv file.

$(document).ready(function()
    {
        $.ajax({
            type : "GET",
            url : "data/application_index1.csv",
            dataType : "text",
            async : false,
            success : 
        function(data)
            {
                console.log(data)
                all_application = CSVToArray(data);
            }
        });

    });

The data count of the csv file is 8.when we are converting the data from the csv file to array,we are getting length of the array as 8 (for one csv file). and for the other csv file the length is 9. Upon debugging the code, below is the data obtained from the csv file (correct one)

"index,application_name
1,Friday Daily Jobs WK1
2,Monday Additional Jobs 
3,"Monday Daily Jobs
"
4,Non Daily Jobs
5,NonBATCHNDC Daily Jobs
6,Others
7,Tue-Fri Daily"

when we convert the above to arrays, we get the length of the array as 8. which is correct. But when we use the other csv file the data we get is the below

"index,application_name
1,Friday Daily Jobs WK1
2,Monday Additional Jobs
3,Monday Daily Jobs
4,Non Daily Jobs
5,NonBATCHNDC Daily Jobs
6,Others
7,Tue-Fri Daily
"

Above is the data that we get when I debug the code.When we convert the above to array, the length of the array becomes 9.The quotes('"') displayed at the last line of the data is considered as one more array. Can someone please explain the reason for the same. Also it would be great how the data is read from the url specified in the ajax() function.

AnyHelp on this is much appreciated. Thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么