Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

206
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!