Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.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 如何在Json上对日期数据表进行排序_Javascript_Jquery_Json_Ajax_Jquery Ui - Fatal编程技术网

Javascript 如何在Json上对日期数据表进行排序

Javascript 如何在Json上对日期数据表进行排序,javascript,jquery,json,ajax,jquery-ui,Javascript,Jquery,Json,Ajax,Jquery Ui,我有两个输入日期 <form id="refresh" method="post" action="income.php"> <input type="text" id="dari" name="dari" /> <input type="text" id="sampai" name="sampai" /> <button type="submit">refresh</button> </form> 添加

我有两个输入日期

<form id="refresh" method="post" action="income.php">
   <input type="text" id="dari" name="dari" />
   <input type="text" id="sampai" name="sampai" />
   <button type="submit">refresh</button>
</form>
添加整个代码income.php

<?php
header('content-type:application/json');

include '../connetion.php';
    $select=mysql_query("select nama_menu, qty, price, disc, tgl_transaksi from tb_transaksi where tgl_transaksi BETWEEN '$_POST[dari]' AND '$_POST[sampai]'");

$row=array();

while($row=mysql_fetch_array($select))
{
    $arrayx=array(  "nama_menu"=>$row['nama_menu'],
                    "qty"=>$row['qty'],
                    "price"=>$row['price'],
                    "disc"=>$row['disc']
                );

    $rows[] = $arrayx;
}

echo json_encode($rows);
?>

您正在使用表单。如果您提交表单,它将刷新页面。相反,将按钮类型设置为button并使用该按钮的click事件

 <form id="refresh" method="post" action="income.php">
       <input type="text" id="dari" name="dari" />
       <input type="text" id="sampai" name="sampai" />
       <button id='ref' type="button">refresh</button>
    </form>

    <script type="text/javascript">
    $(document).ready(function() {
        $('#ref').click(function() {
            $.ajax({
                type: 'POST',
                url: $("#refresh").attr('action'),
                data: $("#refresh").serialize(),
                dataType: 'json',
                success: function(status) {
                    var datanya = JSON.parse(JSON.stringify(status));
                    $('#income').bootstrapTable('refresh', {
                        url: '../../tables/income.php'
                    });
                }
            })
            return false;
        });
    })
    </script>

刷新
$(文档).ready(函数(){
$('#ref')。单击(函数(){
$.ajax({
键入:“POST”,
url:$(“#刷新”).attr('action'),
数据:$(“#刷新”).serialize(),
数据类型:“json”,
成功:功能(状态){
var datanya=JSON.parse(JSON.stringify(status));
$(“#收入”).bootstrapTable('刷新'{
url:“../tables/income.php”
});
}
})
返回false;
});
})

按钮单击“不工作”。我添加了
警报(“a”)点击事件。没有警报出现,这是工作,长官。。但是bootstrap table call income.php仍然没有显示数据。如果我打开manual income.php,它就会工作。但不是为桌子工作。
<?php
header('content-type:application/json');

include '../connetion.php';
    $select=mysql_query("select nama_menu, qty, price, disc, tgl_transaksi from tb_transaksi where tgl_transaksi BETWEEN '$_POST[dari]' AND '$_POST[sampai]'");

$row=array();

while($row=mysql_fetch_array($select))
{
    $arrayx=array(  "nama_menu"=>$row['nama_menu'],
                    "qty"=>$row['qty'],
                    "price"=>$row['price'],
                    "disc"=>$row['disc']
                );

    $rows[] = $arrayx;
}

echo json_encode($rows);
?>
 <form id="refresh" method="post" action="income.php">
       <input type="text" id="dari" name="dari" />
       <input type="text" id="sampai" name="sampai" />
       <button id='ref' type="button">refresh</button>
    </form>

    <script type="text/javascript">
    $(document).ready(function() {
        $('#ref').click(function() {
            $.ajax({
                type: 'POST',
                url: $("#refresh").attr('action'),
                data: $("#refresh").serialize(),
                dataType: 'json',
                success: function(status) {
                    var datanya = JSON.parse(JSON.stringify(status));
                    $('#income').bootstrapTable('refresh', {
                        url: '../../tables/income.php'
                    });
                }
            })
            return false;
        });
    })
    </script>