Dada una tabla, cuando el usuario selecciona una fila, guardo los valores de esa fila en una matriz.
Código:
var outer_array = [] //loop through checked checkboxes $("tbody input[type=checkbox]:checked").each(function(index, item) { var inner_array = [] var selector = $(this).closest("tr") //get closest tr //loop through trs td not first one selector.find("td:not(:first)").each(function() { inner_array.push($.isNumeric($(this).text().trim()) ? Number($(this).text().trim()) : $(this).text().trim()) //push in inner array }) outer_array.push(inner_array) //push in outer array }) Por alguna razón, inner_array contiene caracteres no deseados como el byte: "b'\x00'"
Estos caracteres me causan problemas en el back-end ya que Python interpreta la barra invertida como un carácter especial.
¿Cómo podría deshacerme de esos caracteres de bytes no deseados?
Por ejemplo, en lugar de enviar ese byte, me gustaría enviar una cadena vacía (pseudo):
if (byte_code){ innter_array.push('') } else { inner_array.push($.isNumeric($(this).text().trim()) ? Number($(this).text().trim()) : $(this).text().trim()); }Solo reemplácelos antes
También es más SECO
const text = $(this).text().trim().replace(/b'\\x00'/g,"") inner_array.push($.isNumeric(text) ? Number(text) : text)