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

182
Views
Javascript / ¿Por qué la declaración "else" todavía funciona cuando se cumple la condición en la declaración "if"?

Cuando intenta eliminar la ubicación que tiene dependencias, arroja el mensaje de alerta "¡Hay dependencias en esta ubicación!" pero aun así ve y pregunta "¿Estás seguro de eliminar este registro?"

¿Por qué es esto?

¿Cómo puedo hacer que avise "Hay dependencia(s) en esta ubicación!" y parar ahi?

 $('tbody').on('click', '.deleteLocationBtn', function(e){ const selectedID = e.target.dataset.id let convertIDtoName; for (i = 0; i < arrOfLocation.length; i++) { if (selectedID == arrOfLocation[i].id) { convertIDtoName = arrOfLocation[i].name for (j = 0; j < arrOfDepartment.length; j++) { if (convertIDtoName == arrOfDepartment[j].location) { alert("There's dependencie(s) to this location!") } else { deleteLocation(selectedID) } } } } })
 const deleteLocation = (id)=> { event.preventDefault(); if (confirm('Are you sure to delete this record ?')) { $.ajax({ type: "GET", url: `companydirectory/libs/php/deleteLocationByID.php?id=${id}`, success: function(data) { getAllLocation() $("#location_data_list").load(location.href + " #location_data_list"); }, error: function(request,error) { console.log(request) } }) $("#location_data_list").load(location.href + " #location_data_list"); } }
about 4 years ago · Juan Pablo Isaza
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!