如何读取客户端本地csv文件javascript? [英] How to read local csv file in client side javascript?

查看:370
本文介绍了如何读取客户端本地csv文件javascript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有客户端javascript,我想从本地 csv 文件读取。在html代码中,我使用脚本标记导入本地javascript文件,并且此js文件在另一个文件夹中。

I have client side javascript that I want to read from a local csv file. In the html code, I import a local javascript file using a script tag and this js file is in another folder.

js文件的内容

$.ajax({
    type: "GET",
    url: "./../../data/English.csv",
    dataType: "text",
    success: function(data) {
        alert("worked");
    },
    error: function (request, status, error) {
        alert(request.responseText);
    }
 });

csv文件的路径是相对于html文件的。但是触发错误功能。是否有解决方法?

The path to the csv file is relative to the html file. However the error function is triggered. Is there a way to fix this?

感谢

推荐答案

发现了几个jQuery插件,可以直接解析本地(客户端)CSV文件:

I came across a couple of jQuery plugins that can parse local (client) CSV files directly:


  1. http://papaparse.com/

  2. http://github.com/evanplaice/jquery-csv

  1. http://papaparse.com/
  2. http://github.com/evanplaice/jquery-csv

这篇关于如何读取客户端本地csv文件javascript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆