weixin_33730836 2016-05-10 10:48 采纳率: 0%
浏览 17

如何在AJAX中使用AJAX?

I am using the following JavaScript to get the HTML.

$('#myHref').change(function() {
    var value = $('#myHref').val();
    $.get('get_project.php',{id:value},function(data) { 
        $('#projectDetail').html(data);
        $('#projectDetail').fadeIn('slow');
    }); 
}); 

I use some html in get_project.php as follow:

<select name="sn_id" id="sn_id" >
    <option>Data1</option>
    <option>Data2</option>
    .....
</select> 

I want to select menu and get returned on the basis of it. So again I add the following JavaScript to get value according to selected sn_id:

$('#sn_id').change(function() {
    var value = $('#sn_id').val();
    $.get('calculate_invest.php',{id:value},function(data) { 
        $('#show_me').html(data); 
    }); 
}); 
  • 写回答

1条回答 默认 最新

  • csdnceshi62 2016-05-10 12:24
    关注

    you are dynamically adding your "select" , then you need to add the event in the document, like this:

    $(document).on('change','#sn_id', function() {
        var value = $('#sn_id').val();
        $.get('calculate_invest.php',{id:value},function(data) { 
            $('#show_me').html(data); 
        }); 
    }); 
    
    评论

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退