Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 调用其他php页面的脚本不工作_Javascript - Fatal编程技术网

Javascript 调用其他php页面的脚本不工作

Javascript 调用其他php页面的脚本不工作,javascript,Javascript,需要帮助,按钮不起作用,我主页上的“报告生成器”按钮没有调用report.php页面,在Chrome中,我已经检查了“开发工具”下的“网络”选项卡,当我单击“报告生成器”按钮时,我没有收到任何活动/响应,下面是我的php主页: <script type="text/javascript"> $(document).ready(function(){ $("#RetrieveList").on('click',function() {

需要帮助,按钮不起作用,我主页上的“报告生成器”按钮没有调用report.php页面,在Chrome中,我已经检查了“开发工具”下的“网络”选项卡,当我单击“报告生成器”按钮时,我没有收到任何活动/响应,下面是我的php主页:

<script type="text/javascript">

            $(document).ready(function(){
            $("#RetrieveList").on('click',function() {
                var xid = $('#XiD').val();
                var date = $('#Date').val();
                $.post('retrieve_test.php',{xid:xid, date:date}, function(data){
                $("#results").html(data);
                });
                return false;
            });

            $("#DeletefromDB").click(function() {
                if (confirm("Are you sure you want to delete?"))
                var id = $('input[name=checkbox]:checked').map(function()
                    {
                        return $(this).val();
                    }).get();
                $.post('delete_test.php',{id:id}, function(data){
                $("#result").html(data);
                });

                return false;
            });                 
            });

            $("#Report").on('click',function() {
            var date = $('#Date').val();
                $.post('report.php',{date:date}, function(data){
                $("#results").html(data);
                });
                return false;
            });

    </script>

        <form id="form2" name="form2" method="post" action="">

              <table width="741" border="0" align="center">
                <tr>
                  <th colspan="9" align="center" style="font-size:14px" scope="col">Xid, Name:<span>
                    <select name="XiD" id="XiD">

                      <option value="AAA">AAA</option>
                      <option value="BBB">BBB</option>
                      <option value="" selected="selected">Please Select...</option>
                    </select>
                  </span><span style="font-size:14px">
                  <label for="date">Date:</label>
                  <input type="text" name="Date" id="Date" size="8"/>
                  </span></th>
                </tr>
                <tr>
                  <th colspan="9" scope="col">&nbsp;</th>
                </tr>
                <tr>
                  <th colspan="9" scope="col">
                    <div align="center">
                      <input name="action" type="button" id="RetrieveList" value="Retrieve List" />
                      <input name="action" type="button" id="DeletefromDB" value="Delete from DB" />
                      <input name="Clear" type="reset" id="Clear" value="Clear" onClick="window.location.reload()" />
                  <input name="action" type="button" id="Report" value="Report Generator" />
                    </div>
                    <label for="Clear"></label>
                    <div align="center"></div></th>
                </tr>

              </table>
              </form>
            <div id="results">
            </div>

$(文档).ready(函数(){
$(“#RetrieveList”)。在('click',function()上{
var xid=$('#xid').val();
var date=$('#date').val();
$.post('retrieve_test.php',{xid:xid,date:date},函数(数据){
$(“#结果”).html(数据);
});
返回false;
});
$(“#DeletefromDB”)。单击(函数(){
如果(确认(“您确定要删除吗?”))
var id=$('input[name=checkbox]:checked').map(函数()
{
返回$(this.val();
}).get();
$.post('delete_test.php',{id:id},函数(数据){
$(“#结果”).html(数据);
});
返回false;
});                 
});
$(“#报告”)。在('click',function()上{
var date=$('#date').val();
$.post('report.php',{date:date},函数(数据){
$(“#结果”).html(数据);
});
返回false;
});
Xid,名称:
AAA
BBB
请选择。。。
日期:
以下是我的report.php页面代码:

<?php
    require 'include/DB_Open.php';

    $date = $_POST['date'];

    $sql="SELECT trouble_type_priority, category_1, category_2, status, COUNT (*) AS Total 
               FROM tbl_main 
               WHERE resolved_date = '$date'
               GROUP BY trouble_type_priority, category_1, category_2, status";

    $myData = mysql_query($sql)or die(mysql_error());

    echo "<table width='auto' cellpadding='1px' cellspacing='0px' border=1 align='center'>
    <tr>
        <th colspan='3' align='center'>Ticket Bucket</th>
        <th colspan='3' align='center'>Status</th>
    </tr>
    <tr>
        <th width='auto' align='center'>Severity</th>
        <th width='auto' align='center'>Category 2</th>
        <th width='auto' align='center'>Category 3</th>
        <th width='auto' align='center'>Resolved</th>
        <th width='auto' align='center'>Re-assigned</th>
        <th width='auto' align='center'>Grand Total</th>
    </tr>";

    while($info = mysql_fetch_array($myData)) 
    {
    echo"<tr>"; 

    echo  "<td align='center'>" . $info['trouble_type_priority'] . "</td>"; 
    echo  "<td align='center'>" . $info['category_1'] . "</td>"; 
    echo  "<td align='center'>" . $info['category_2'] . "</td>"; 
    echo  "<td align='center'>" . $info['status'] . "</td>"; 
    echo "</tr>"; 
    }
    echo "</table>"; 


    include 'include/DB_Close.php';
    ?>

您为报告按钮设置
onclick
事件的代码似乎不在
$(document).ready(…)
函数的范围内。现在,您的javascript将在页面的其余部分准备就绪之前执行,此时将不会有报告按钮向其中添加事件


我想,这可能就是问题所在。尝试将
$(“#报告”).on('click',…)
移动到
$(document).ready(…)
回调函数中。

您为报告按钮设置
onclick
事件的代码似乎不在
$(document).ready(…)
函数中。现在,您的javascript将在页面的其余部分准备就绪之前执行,此时将不会有报告按钮向其中添加事件


我想,这可能就是问题所在。尝试将
$(“#报告”).on('click',…)
移动到
$(document).ready(…)
回调函数中。

我无法设置注释格式,但为了获得更多关于正在发生的事情的信息,您可以控制台吗。记录一些事情:不确定这是否有帮助,但将date属性放在引号中:{'date':date}

        console.log("adding click handler to:",$("#Report"));
        $("#Report").on('click',function() {
           console.log("date will be:",$('#Date').val());
           var date = $('#Date').val();
            $.post('report.php',{'date':date}, function(data){
            $("#results").html(data);
            });
            return false;
        });

我无法格式化注释,但为了获得有关正在发生的事情的更多信息,您可以console.log一些事情:不确定这是否有帮助,但将date属性放在引号中:{'date':date}

        console.log("adding click handler to:",$("#Report"));
        $("#Report").on('click',function() {
           console.log("date will be:",$('#Date').val());
           var date = $('#Date').val();
            $.post('report.php',{'date':date}, function(data){
            $("#results").html(data);
            });
            return false;
        });

您是否收到js错误或smth。还有吗?你有js错误或smth吗。还有?漂亮的眼睛…我怎么可能看不到…我想我已经太累了…无论如何…谢谢你的帮助…漂亮的眼睛…我怎么可能看不到…我想我已经太累了…无论如何…谢谢你的帮助。。。