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>