Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

306
Vistas
How to call a Javascript AJAX function after button click?

I have searched this online but I am stuck. I am calling a JavaScript function button click. It does not work unless I wrap it in $(document).ready(function() {}). However, I need to run the function not just after page load, but right after button click.

HTML Button :

<a href="/Spend/Job" onclick="return getisModified()" class="btn btn-default">Config </a>

JavaScript :

var isModified;

function getisModified() {
  $.get("/Spend/Job/IsModified", function (data, status) {
    if (status === "success" && data && data.length > 0) {
      var dataObj = JSON.parse(data);
      isModified = dataObj.IsModifiedAny;
    }
  });

  if (isModified == true) { //if there are any modified rows
    var response = confirm("You have made changes without running Config. Continue anyway?")
    if (response) //user clicks OK
      {
        return true
      } else { //user clicks cancel
        return false
      }
  }
} 

The code works when i run it in the console. But not when it is called after button click.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda