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

152
Views
¿Cómo paso la identificación de la función a la promesa. todo en jQuery?

Quiero pasar la identificación del valor seleccionado anterior a otra función de selección. Tengo 3 menús de selección que dependen entre sí. Ejemplo

el usuario tiene que seleccionar el estado primero que el distrito, luego puede seleccionar el valor de la ciudad.

Con este código obtuve el error de Uncaught ReferenceError: a is not defined ¿Cómo resolver esto?

Esto es lo que he probado

 $(document).ready(function() { $("#state").change(function() { let state = $(this).val(); getDistrict(state); }); $("#district").change(function() { let district = $(this).val(); getCity(district); }); }); function getStateList() { return axios.get(`${url}state`); } function getDistrict(state) { return axios.get(`${url}dist?state_id=${state}`); } function getCity(district) { return axios.get(`${url}city?district_id=${district}`); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

El problema es que a y b no están declarados. Puede usar el state var para llamar a getDistrict , porque lo usa en el entorno de su función.

Si desea acceder al state como a y al district como b , debe declararlos fuera de sus funciones. Esto podría ser algo como esto:

 var a; var b; $(document).ready(function() { $("#state").change(function() { a = $(this).val(); getDistrict(a); }); $("#district").change(function() { b = $(this).val(); getCity(b); }); }); function getStateList() { return axios.get(`${url}state`); } function getDistrict(state) { return axios.get(`${url}dist?state_id=${state}`); } function getCity(district) { return axios.get(`${url}city?district_id=${district}`); } Promise.all([getStateList(), getDistrict(a), getCity(b)]) .then(function(results) { //code });
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!