The element cannot be found after Ajax request



  • There's no way we can find an id element for the block. htmlwhich is formed and comes from the server through Ajax request. There's a choice block in the browser. selectbut $("#test").on('change', function() He can't see.

    It is remarkable that when using this code without Ajax on the html page, everything works. Please help me understand the problem.

    $("#test").on('change', function() {
        b = $(this).val();
        console.log(b);
    });
    
    <select id="test">
        <option>Выберите значение</option> 
        <option value="1">Первый элемент</option>    
        <option value="2">Второй элемент</option>  
    </select>
    


  • You need to. $('#u_money_s').html(html); She'll give you a response to the html

    $('#u_money').submit(function(){
      var str = $(this).serialize();
      $.ajax({
        type:"POST",
        url:"inc/adm.php",
        data:str,
        success:function(html){
          $('#u_money_s').html(html);
        }
    

    });
    return false;
    });


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2