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

107
Visualizações
On change of select not triggered in wordpress

I am trying to trigger an onchange ajax query but it is not working. In the beginning I am changing some innerHTML, then populate a through an ajax query before the user can select any dropdown lists. Finally I want to trigger an on change of location to make another ajax query. Unfortunately the code is not working. All code is in one test.js file

   jQuery(document).ready(function($){
    var locationDiv = document.getElementById('locations-ddl');
    var selectionDivLoc = locationDiv.querySelector('.wpv-custom-search-filter__input');
    selectionDivLoc.innerHTML = '<select id="location" name="location"></script>';

    var repositoryDiv = document.getElementById('repositories-ddl');
    var selectionDivRep = repositoryDiv.querySelector('.wpv-custom-search-filter__input');
    selectionDivRep.innerHTML = '<select id="repository" name="repository"></script>';

    var fondDiv = document.getElementById('fonds-ddl');
    var selectionDivFond = fondDiv.querySelector('.wpv-custom-search-filter__input');
    selectionDivFond.innerHTML = '<select id="fond" name="fond"></script>';

    var seriesDiv = document.getElementById('series-ddl');
    var selectionDivSeries = seriesDiv.querySelector('.wpv-custom-search-filter__input');
    selectionDivSeries.innerHTML = '<select id="series" name="series"></script>';




  $.ajax({
      
      'url' : ajaxurl,
      data: {
          'action':'get_locations', // This is our PHP function below
      
      },
      success:function(data) {
  // This outputs the result of the ajax request (The Callback)
          $("#location").replaceWith(data);
      },
      error: function(errorThrown){
          window.alert(errorThrown);
      }
  });
    



 jQuery('#location').change(function(){
    window.alert('yep');
    $.ajax({
      
      'url' : ajaxurl,
      data: {
          'action':'test', // This is our PHP function below
      
      },
      success:function(data) {
            window.alert(data);
      },
      error: function(errorThrown){
          window.alert(errorThrown);
      }
  });
});
about 4 years ago · Juan Pablo Isaza
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