【问题标题】:In new window jquery functions not working在新窗口中 jquery 功能不起作用
【发布时间】:2017-03-03 14:31:16
【问题描述】:

我的项目中有这段代码可以打开一个新窗口来显示,然后从我的第一个窗口写入内容。之后我用某个页面替换了某个 div,但是在这个窗口中,javascript 函数不起作用。如何在newl 生成的寡妇中启用javascript 功能? 这是我的窗口生成 jquery 脚本

$('.ledger_edit').on('click', function (e) {
        e.preventDefault();

        var mywindow = window.open(window.location.href);
        $(mywindow.document).ready(function () {
            $.ajax({
            url: $(this).attr('href'),

                success: function (data)
                {

                    $(mywindow.document).contents().find("div.content").html(data);
                    mywindow.onload = function () {
                        alert()

                        mywindow.contents().find(".ledger").select2();
                        calculateTotal();

                    }

                }
            });

        });

    })

我的新窗口内容 div 替换为下面的 html 代码

    <form method="post" action="#">
                <input type="hidden" id="PID" name="PID" value="">
          <input type="hidden" id="action" name="action" value="update_project">
 ...
        <input type="button" id="proj_submit" class="ui blue submit button right floated" value="Update">
            </form></div>
<script>
$(document).ready(function() {
 $( "form" ).on( "submit", function(e) {
     e.preventDefault();
    data = $(this).serialize();
     $.ajax({
        type:"POST",
        url: "functions_new.php",
        data:data,
        success: function() {
            alert("Updated");
        }
});
});
});

【问题讨论】:

    标签: javascript php jquery dom codeigniter-3


    【解决方案1】:
    $new_date =  date('Y-m-d', strtotime($date));
    

    希望这会奏效。

    【讨论】:

    • 你从中得到了什么? $date = ($date - 25569) * 86400;
    • 这是输入日期 02/06/2016,然后我得到了这个方程 float(-2209161600),
    • date('Y-m-d', strtotime($date)) 结果答案 2016-10-22
    • 可以跳过这一步 $date = ($date - 25569) * 86400;
    • 然后我得到了结果 1970-01-01
    【解决方案2】:

    尝试使用strtotime()函数,

    $new_date = date('Y-m-d', strtotime($date));
    

    【讨论】:

    • $date 会给你带来什么价值?
    • 这是输入日期 02/06/2016,然后我得到了这个方程 float(-2209161600),
    • date('Y-m-d', strtotime($date)) 结果答案 2016-10-22
    • 我输入的日期是 02-06-2016,但我得到的结果是 2016-10-22
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-11
    • 1970-01-01
    • 2016-10-23
    • 1970-01-01
    • 2015-09-27
    • 1970-01-01
    相关资源
    最近更新 更多