Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

209
Vistas
How do I send id in array in form append?

I have this delete function that when user click it will push the id into delete array. User can delete multiple picture by click one by one icon trash. And to save thier commit changes about the delete item they have to click on the save button. But I have problem in sending the data in the form append.

enter image description here

output that I want to achieve is it will send the id the format like this

[64,65]

But currently it only send like this

64,65

enter image description here

my code


<a href="#javascript:;" onclick="deleteDoc('${e.doc.id}')"></a>

const deleteDoc = (id) =>{
    deleteDoc_temp.push(id);
}

const update = () => {

    let deleteDoc =  deleteDoc_temp; 

    let formData  = new FormData();
 
    formData.append('deleted_attachment', deleteDoc);
   
    for (var pair of formData.entries()) { console.log(pair[0]+ ', ' + pair[1]); }
}



How do I fix this problem to make sure that I can achieve output in append form like this ?

[64,65]
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Use the function JSON.stringify to the array. In your case :

Change

    formData.append('deleted_attachment', deleteDoc);

to

    formdata.append('deleted_attachment', JSON.stringify(deleteDoc));

or else you could just do

    deleteDoc.forEach((item) => formData.append("deleted_attachment[]", item));
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda