解决方案 »
- 求一段用于验证用户名和密码输入是否规范的JS代码
- ASP从SQL中读取数据 显示问题
- 新手问题:关于marquee不能在浏览器中滚动的问题
- 一个多选下拉框,选中其中某一下,我想通过一个按钮,可以把选中的项移动到最顶部。
- 怎样在HTML中用javascript调用服务器用户控件》??
- 各位大哥!给点意见:想学习javascript,有什么书介绍!!!
- SOS~~用JS怎么遍历一个表单的所有元素?
- ----------------dataTable-------分页的问题---------------------
- JS页面中的值如何传到JSP编写的后天方法中去????
- js新手菜鸟求助各位大神指点,实现不了div背景切换啊,代码:
- 关于 jQuery validate 的一个自定义验证方法,
- 组合排列算法
$('#sq').datagrid({
title:'Stores sales quantity performance',
url: 'get_salesquantityper.php',
singleSelect: true,
rownumbers:true,
frozenColumns:[[{field:'Category',title:'Category'}]],
columns:data///xxxxxx那个页面输出column需要的内容
}); },error:function(xhr){
alert('动态页有问题或者返回了不标准的JSON字符串\n'+xhr.responseText);
}})
$stt="[[{colspan:'3',title:'2013Dec'}],[{field:'name',title:'Name', width:'80', align:'right'},{field:'price',title:'Price',width:'80',align:'right'},{field:'price',title:'Price',width:'80',align:'right'}]]";
//$stt='[[{colspan:"3",title:"2013Dec"}],[{field:"name",title:"Name", width:"80", align:"right"},{field:"price",title:"Price",width:"80",align:"right"},{field:"price",title:"Price",width:"80",align:"right"}]]';
//echo json_encode($a);
//echo $stt;
echo json_encode($stt);
返回的json总是带两个引号,页面也不能正常显示。 是转换错了吗?下面这个问题您一起把分拿走吧
http://bbs.csdn.net/topics/390729264
$stt='[[{"colspan":"3","title":"2013Dec"}],[{"field":"name","title":"Name", "width":"80", "align":"right"},{"field":"price","title":"Price","width":"80","align":"right"},{"field":"price","title":"Price","width":"80","align":"right"}]]';
//直接输出就好了,不用json_encode,你的不是对象,是字符串
echo $stt;
error:function(xhr){
alert('动态页有问题或者返回了不标准的JSON字符串\n'+xhr.responseText);
}已经验证了....
$('#sq').datagrid('reload',{bt:$('#bt').val(),et:$('#et').val()});
但现在因为列名也要随数据一起跟新,该怎么写?
$('#sq').datagrid('reload',{bt:$('#bt').val(),et:$('#et').val()});
但现在因为列名也要随数据一起跟新,该怎么写?
看你php版块的帖子,清空datagrid的生成的html,放置一个空的table容器重新构造datagrid,你的url也要同时更新(如修改url参数什么的),重新加载数据还是你原来的方法
$('#sq').datagrid('reload',{bt:$('#bt').val(),et:$('#et').val()});
但现在因为列名也要随数据一起跟新,该怎么写?
看你php版块的帖子,清空datagrid的生成的html,放置一个空的table容器重新构造datagrid,你的url也要同时更新(如修改url参数什么的),重新加载数据还是你原来的方法
点击查询按钮时触发下面的事件(用于生成新的表格列名和表中的数据)
function getD()
{
$('#divDatagrid').html('<table id="salesquantityper"></table>');
alert($('#bt').val());
$.ajax({url:'get_salesquantityper.php?type=initrows',
type:"POST",
dataType:'json',
data:{bt:$('#bt').val(),et:$('#et').val()}
,success:function(data){
$('#salesquantityper').datagrid({
title:'Stores sales quantity performance',
url: 'get_salesquantityper.php',
width:'auto',
singleSelect: true,
rownumbers:true,
frozenColumns:[[{field:'Category',title:'Category'}]],
columns:data
}); },error:function(xhr){
alert('动态页有问题或者返回了不标准的JSON字符串\n'+xhr.responseText);
}})
}
在测试时后台能获得前台传来的数据但报错,
function getD()
{
$('#divDatagrid').html('<table id="salesquantityper"></table>');
// alert($('#bt').val());
$.ajax({url:'get_salesquantityper.php?type=initrows',
type:"POST",
dataType:'json',
data:{bt:$('#bt').val(),et:$('#et').val()}//这句代码已经把bt和et传到了后台(get_salesquantityper.php)
,success:function(data){
$('#salesquantityper').datagrid({
title:'Stores sales quantity performance',
url: 'get_salesquantityper.php',//这里却取不到动态的数据。
width:'auto',
singleSelect: true,
rownumbers:true,
frozenColumns:[[{field:'Category',title:'Category'}]],
columns:data
});
// $('#salesquantityper').datagrid('reload',{bt:$('#bt').val(),et:$('#et').val()}); },error:function(xhr){
alert('ajax error\n'+xhr.responseText);
}})
}后台代码
include_once 'DB_connmssql.php';
$l_mb =str_replace('-','',date("Y-m-d",strtotime("-3 month")));
$l_me= str_replace('-','', date("Y-m-d",strtotime("-0 month")));$start_date = isset($_POST['bt']) ? substr(str_replace('-','',$_POST['bt']),0,6):substr($l_mb,0,6);
$end_date = isset($_POST['et']) ? substr(str_replace('-', '',$_POST['et']),0,6) :substr($l_me,0,6);$type=$_REQUEST['type'];if($type=='initrows'){
//echo $start_date."@^^@".$end_date;能动态取得时间
echo initRows4(xx1($start_date),xx1($end_date),1);
}else{
echo $start_date."@@@".$end_date;//不能动态取得时间
}