Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

446
Visualizações
Ajax : Why success displays 0?

I use ajax with jquery and when I tried to display the result in popup. Then alert always displays 0

success : function(results) { 
alert(results); }

EDIT :

 var dataToSend = {
    action:"ACTION_NAME",
    id : "12"
  };
  url_action = 'http://www.______.com/wp-admin/admin-ajax.php';
  $.ajax({
          url: url_action,
          type:'POST',
          data: dataToSend,
          success:function(results)
          {
             alert(results);
          }
   });
over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Try to add die(); or exit(); at the very last line of the function.

over 4 years ago · Santiago Trujillo Relatório

0

May be you are trying without login. so you need to use this action.

add_action('wp_ajax_nopriv_my_action', 'my_action_callback');

you will get response. :)

over 4 years ago · Santiago Trujillo Relatório

0

I had a similar issue with admin-ajax.php returning 0, even i had die().

My problem was that the add_action was declared in a file not loaded default by plugin.

Anyway, if you have problem also check in browser what __.com/wp-admin/admin-ajax.php?action=youraction returns.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda