mardi 29 juin 2021

Javascript cannot use in operator to search for length in

I get the error when clicking in the datatable search bar and typing anything followed by backspace. Not sure why I'm getting this error but some help and explanation would be awesome and very appreciated. Here's the relevant code below with exact error message. Also the lines it says the error comes from are wrong since flask doesn't create proper error messages

Uncaught TypeError: Cannot use 'in' operator to search for 'length' in 
    at s (jquery.min.js:2)
    at Function.map (jquery.min.js:2)
    at Na (jquery.dataTables.min.js:40)
    at ub (jquery.dataTables.min.js:39)
    at ca (jquery.dataTables.min.js:38)
    at L (jquery.dataTables.min.js:27)
    at ra (jquery.dataTables.min.js:44)
    at HTMLTableElement.<anonymous> (jquery.dataTables.min.js:91)
    at Function.each (jquery.min.js:2)
    at n.fn.init.each (jquery.min.js:2)
const sendRequest = (elName) => {
  $.ajax({
    url: "/?????",
    contentType: "application/json",
    type: "POST",
    data: JSON.stringify(elName),
    dataType: "JSON",
    success: function(res) {},
  });
};

const pullValues = () => {
  processName = JSON.stringify('');
  creationTime = JSON.stringify('');
  finishTime = JSON.stringify('');
  return processName, creationTime, finishTime;
}

const createButtons_Table = function() {
  $.ajax({
    url: "/?????",
    contentType: "application/json",
    type: "POST",
    dataType: 'JSON'
  }).done(function(response) {
    result = response;
    resultLen = result.length - 1;
    for (let i = 0; i < resultLen; i++) {
      btnElements.innerHTML += `<button class='button-machines' name=${result[i]} id='button-${i}'>${result[i]}</button>`;
      for (let x = 0; x < resultLen; x++) {
        let buttons = $(`#button-${x}`);
        buttons.click(function() {
          btnNames = document.getElementById(`button-${x}`).name;
          machineTableEl = $("#machine-table");
          tableBody = document.getElementById("machine-info-body");
          tableBody.innerHTML = `
                                    <tr><td>${x}</td>
                                        <td>${btnNames}</td>
                                        <td>FILLERINFO</td>
                                        <td>FILLER</td>
                                        <td>FILLER</td>
                                    </tr>`;
          sendRequest(btnNames);
          machineTableEl.removeAttr("style");
          $('#approved-software-list-right').removeClass('hidden');
        });
      }
    }
  });
  $('#machine-table').DataTable();
}



Aucun commentaire:

Enregistrer un commentaire