<%-- 
    Document   : index.jsp
    Created on : 22-jun-2018, 12:51:27
    Author     : sistem17user
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <input type="file" accept=".csv" id="filePrueba">
        <button id="btnCargar">Cargar</button>
        <pre id="txtJson">
            
        </pre>
        <script src="../plantilla/assets/js/core/libraries/jquery.min.js" type="text/javascript"></script>
        <script src="../plantilla/assets/js/core/libraries/bootstrap.min.js" type="text/javascript"></script>
        <script src="../plantilla/assets/js/plugins/papaparse/papaparse.js" type="text/javascript"></script>
        <script type="text/javascript">
               $('#btnCargar').click(function () {
                  var archivo;
                  $('#filePrueba').parse({
                     header: true,
                     dynamicTyping: false,
                     encoding: "ISO-8859-1",
                     before: function (file) {
                        archivo = file;
                     }
                  });
                  Papa.parse(archivo, {
                     header: true,
                     dynamicTyping: false,
                     encoding: "ISO-8859-1",
                     complete: function (results) {
                        $('#txtJson').html(JSON.stringify(results.data, undefined, 2))
                     }
                  })
               })
        </script>
    </body>
</html>
