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

384
Views
Error de JQuery $.ajax: no hay ningún encabezado 'Access-Control-Allow-Origin' en el recurso solicitado

Tengo una solicitud JQuery ajax que me arroja un error:

El acceso a XMLHttpRequest en 'http://localhost:8080/api/v1/2523/export-pdf' desde el origen 'http://xxxxx.localhost' ha sido bloqueado por la política de CORS: la respuesta a la solicitud de verificación previa no pasa el acceso comprobación de control: no hay ningún encabezado 'Access-Control-Allow-Origin' en el recurso solicitado.

Pero estoy bastante seguro de que tengo Access-Control-Allow-Origin: * configurado correctamente. Este es el objeto de solicitud, donde puede ver el encabezado Access-Control-Allow-Origin.

 Accept: */* Access-Control-Allow-Origin: * Content-Type: application/x-www-form-urlencoded; charset=UTF-8 Referer: http://xxxxxx.localhost/ sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="102", "Google Chrome";v="102" sec-ch-ua-mobile: ?0 sec-ch-ua-platform: "Windows" User-Agent: Mozilla/5.0 ...

Este es el código js:

 var data = { lang: lang, client: company, campaign_name: campaign_name, crm_token: {$api_token}, }; var url = {$api_url} + campaign_id + '/export-pdf'; $.ajax(url, { headers: { 'Access-Control-Allow-Origin': '*' }, type: 'POST', data: data, dataType: 'application/pdf', crossDomain: true, success: function(data) { console.log('result data'); console.log(data); var downloadUrl = window.URL.createObjectURL(new Blob([data])); var link = document.createElement('a'); link.href = downloadUrl; link.setAttribute('download', fileName); document.body.appendChild(link); link.click(); link.remove(); error: function (data) { form.find('#pdfExportFormErrors').removeClass('d-none').html('PDF download error.'); });

¿Qué estoy haciendo mal? Por favor ayuda. Gracias.

about 4 years ago · Santiago Gelvez
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!