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

230
Vistas
Why is undefined the ajax response value?

I have a function which returns the pictures for 2 type of devices. In function(response) i get the value correctly, then autside of $.post section the value is undefined.

function findHeadShot(key) {
          var tip;
          var ajaxUrl = "gettip.php";
          var data = { action: 'function1', azon: key};
              $.post(ajaxUrl, data, function(response) {
                  tip = response; //Here i get the response, and it is fine yet
              });
              alert(tip);         //Here the response is undefined, but why?
              switch (tip) {
                case "pc":
                   return "pc_icon.png";
                  break;

                case "server":
                   return "server_icon.png";
                  break;
              
                default:
                  return "server_icon.png";
                  break;
              }
      }
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