title: How to read excel file into json and send to CFC for database insertion?
body: <p>I am reading an excel file using "xlsx.full.min.js" plugin and getting the file data into JSON object.Then I am sending this JSON object to Coldfusion Component (CFC) using jQuery Ajax , but it gives me an error as '400 Bad request'. The CFC is not getting the JSON data that I am trying to send. What is wrong in my code?</p>
  
  <pre><code>var selectedFile = evt.target.files[0];
                      var reader = new FileReader();
  
                      reader.onload = function(event) {
  
                            var data = event.target.result;
                            var workbook = XLSX.read(data, {
                                type: 'binary'
                            });
  
                            workbook.SheetNames.forEach(function(sheetName) {
                                   var excel_json = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName]);
  
                                  var json_object = JSON.stringify(excel_json);
  
                                  $.ajax({
                                      url:"maps.cfc",
                                      dataType: "json",
                                      data: {
                                          method:"updateFuelPrices",
                                          jsstruct:json_object
                                      },
  
                                      success: function(data) {
                                          console.log(data);
                                          console.log("update successful");
                                      },
                                      error: function(xhr, textStatus, errorThrown) {
                                          console.log(textStatus);
                                          console.log(errorThrown);
                                          console.log("Something went wrong! Please refresh the page and try again.");
                                      }
                                  })
                              })
                      };
  
                      reader.onerror = function(event) {
                        console.error("File could not be read! Code " + event.target.error.code);
                      };
  
                      reader.readAsBinaryString(selectedFile);
                });
  </code></pre>
  
  <p>And my CFC function is: </p>
  
  <pre><code>&lt;cffunction name="updateFuelPrices"  output="false" access="remote" returnformat="json" returntype="string"&gt;
          &lt;cfargument name="jsstruct" type='string' required="true"&gt;
          &lt;cfset returntext = 'json sent successfully...'&gt;
          &lt;cfdump var="#ARGUMENTS.jsstruct#"&gt;
           &lt;!--- DB insert query to go here ---&gt;
          &lt;cfreturn returntext&gt;
      &lt;/cffunction&gt;
  </code></pre>