0

我正在尝试实现 - 当我单击链接 Name of movie时,调用 getSummary 函数并且 iframe.php 数据显示在摘要div 中。下面的代码有效,但是,有一个问题。摘要div中的脚本(如本例中的 datepicker)将不起作用(但是它们仍然在不是通过 ajax 制作的 div 中工作)。我做错了什么?谢谢参观!

索引.php

    <html>
        <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    ... other scripts ...

<script type="text/javascript">
    function getSummary(id)
    {
       $.ajax({

         type: "GET",
         url: 'include/iframe.php',
         data: "id=" + id, // appears as $_GET['id'] @ ur backend side
         success: function(data) {
               // data is ur summary
              $('#summary').html(data);
         }

       });

    }
    </script>
    </head>
        <body>

    <a href="javascript:void(0);" class="movie" onclick="getSummary(2)">Name of movie</a <br/>

    <div id="summary">Here is summary of movie</div>

        </body>
    </html>

包括/iframe.php

<form class="form-horizontal">
              <fieldset>
                <div class="input-prepend">
                  <span class="add-on"><i class="icon-calendar"></i></span><input type="text" name="range" id="range" />
                </div>
              </fieldset>
            </form>
4

2 回答 2

0

您是否尝试过重新初始化 datapicker 插件?但是,如果您需要处理诸如“单击”之类的事件,则需要绑定它:$(elementcontainer).on("click","elementtoclick",function (){...})

于 2013-02-27T21:16:31.737 回答
0

我认为您需要在将 dom 添加到文档后绑定事件侦听器。或者使用 on 绑定代替http://api.jquery.com/on/

于 2013-02-27T21:11:26.187 回答