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

216
Views
Coldfusion insertando registro db y descargando archivo usando Ajax

Estoy tratando de crear un botón que, cuando se hace clic, inserta un registro en la base de datos y luego descarga un archivo. Estoy tratando de hacer esto a través de Ajax, la descarga del archivo funciona pero no está insertando el registro en la base de datos.

Generar

 <button type="button" class="btn btn-primary" onClick="downloadFile1()">Download</button>

Guion

 function downloadFile1(){ var file1 = 'https://example.com/files/myfile.zip'; $.ajax({ TYPE: "POST", URL: "components.cfc?method=DownloadFile1", data: {fileId : 3}, success: function() { window.location = file1; } }); } </script>

Componentes.cfc

 <cfcomponent output="false"> <cffunction name="DownloadFile1" access="remote" returntype="string"> <cfcontent type="text/html"> <CFQUERY NAME="i"> INSERT into t_terms (bid, fildid) VALUES ( <cfqueryparam value="#session.busid#" cfsqltype="CF_SQL_INTEGER">, <cfqueryparam value="#url.fileID#" cfsqltype="CF_SQL_INTEGER">) </CFQUERY> </cffunction>

¿Alguien podría señalar dónde me estoy equivocando?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Como Jack dijo anteriormente, dado que está haciendo una POST y no un GET, en lugar de buscar en el alcance de la URL, intente buscar en el alcance del "FORMULARIO".

 <cfqueryparam value="#form.fileID#" cfsqltype="CF_SQL_INTEGER">

O simplemente puede buscar "fileID". Si se está pasando, su consulta funcionará. Si no, arrojará un error.

 <cfqueryparam value="#fileID#" cfsqltype="CF_SQL_INTEGER">
over 4 years ago · Santiago Trujillo 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!