2

guy's i have a problem with passing input type file value into ajax url=url, i hope someone can help me with this. i have code like this

var data;
$.ajax({
  type: "GET",
  url: "js-tutorials.com_sample_file.csv",
  dataType: "text",
  success: function(response) {
    data = $.csv.toArrays(response);
    generateHtmlTable(data);
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-csv/0.71/jquery.csv-0.71.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<div class="container" style="padding:10px 10px;">
  <h1>Read CSV file using JavaScript</h1>
  <div id="header"></div>
  <div class="well">
    <div class="row">
      <form class="form-inline">
        <div class="form-group">
          <label for="files">Upload a CSV formatted file:</label>
          <input type="file" id="files" class="form-control" accept=".csv" required />
        </div>
        <div class="form-group">
          <button type="submit" id="submit-file" class="btn btn-primary">Upload File</button>
        </div>
      </form>
    </div>
    <div class="row">
      <div class="row" id="parsed_csv_list">
      </div>
    </div>
  </div>
  <div id="footer"></div>
</div>

i will explain it from my code. i want to pass the url from file that have choose from input type file from my html into the url: "js-tutorial.com_sample_file.csv";.

Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252
Minervaz Mine
  • 273
  • 1
  • 3
  • 17

0 Answers0