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

122
Views
Invocación ilegal al enviar datos de formulario al servidor PHP usando ajax

Cuando ejecuto el código me sigue saliendo este error:

TypeError no capturado: invocación ilegal

¿Cómo puedo solucionar esto?

 const formdata = new FormData(); for (const file of myfile.files) { formdata.append("myFiles[]", file); } $.ajax({ url: '/all_backend_stuff/server.php', type: 'POST', data: { "file": formdata }, success: function(response) { alert(response); }, complete: function() {} });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <input type="file" id="myfile" name="myFiles[]" accept=".pdf,.jpg,.png">

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Al enviar FormData en una solicitud jQuery AJAX, debe proporcionar el objeto directamente a la propiedad de data (no como el valor de una propiedad dentro de un objeto).

Además, debe configurar contentType y processData en false :

 $.ajax({ url: '/all_backend_stuff/server.php', type: 'POST', data: formdata, contentType: false, processData: false, success: function(response) { alert(response); }, complete: function() {} });
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!