-1

I'm trying to submit a .tsv file and then using d3.js to convert the .tsv file. (That later on will be used to plot a graph)

The d3.js is returning 404 file not found, is it the submit that is not working, or am I not calling the d3.tsv method correctly. Feels like its trying to execute the d3 part before I select the file

Edit: Added .submit for the #file-input

$('#fileSubmit').on('click', function() {
  $('#file-input').trigger('click');
  $('#file-input').on('change', function(){
    $('#file-input').submit()(function{
      alert("Submited!");
       d3.tsv($('#file-input.'), function(data){console.log(data);})
    });
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
  <button id="fileSubmit">Open</button>
  <input id="file-input" type="file" name="name" style="display: none;" />

</body>
R1z1a
  • 33
  • 8

1 Answers1

0

Try this, you don't need a .submit() function:

$('#fileSubmit').on('click', function() {
  $('#file-input').trigger('click');
  $('#file-input').on('change', function(){
      alert("Submited!");
      /* I don't know how d3 works so not sure what this is supposed to do */
      d3.tsv($('#file-input'), function(data){console.log(data);})
  });
});
StudioTime
  • 22,603
  • 38
  • 120
  • 207
  • d3.tsv(myFile.tsv, function(data){console.log(data);}) So the file that I select needs to go into the d3.tsv() - then i will plot graphs from it https://gist.github.com/mbostock/3305937 – R1z1a Apr 10 '17 at 13:07
  • Ok, have a look at this then http://stackoverflow.com/questions/12281775/get-data-from-file-input-in-jquery – StudioTime Apr 10 '17 at 13:10