我正在使用 JQgrid 来显示数据库记录。现在根据我的需要,我将请求传递给处理程序文件以使用 jquery ajax 调用检索数据。但是除了 jason 数据字段之外,所有其他数据字段都将出现。下面我发布我的 .handler 和.aspx 代码..
.handler 来自服务器代码的文件..
json ="";
json = json + "{\n";
json = json + " \"page\":\""+intpage+"\",\n";
json = json + "\"total\":"+total_pages+",\n";
json = json + "\"records\":"+total+",\n";
json = json + "\"rows\": [";
rc =false;
while(rs.Read()){
if(rc){
json = json + ",";
}
json = json + "\n{";
json = json + "\"price\":\"" + Convert.ToInt32(rs["price"]) + "\",";
json = json + "\"cell\":[" + Convert.ToInt32(rs["price"]) + "";
json = json + ",\"" + Convert.ToString(rs["username"]) + "\"";
json = json + ",\"" + Convert.ToString(rs["ordinal"]) + "\"";
json = json + ",\"" + Convert.ToString(rs["authcode"]) + "\"";
json = json + ",\"" + Convert.ToString(rs["extension"]) + "\"";
json = json + ",\"" + Convert.ToString(rs["trunk"]) + "\"";
json = json + ",\"" + Convert.ToString(rs["dialnumber"]) + "\"";
json = json + ",\"" + Convert.ToString(rs["dialdate"]) + "\"";
json = json + ",\"" + Convert.ToString(rs["dialtime"]) + "\"";
json = json + ",\"" + Convert.ToString(rs["duration"]) + "\"";
json = json + ",\"" + Convert.ToString(rs["destination"]) + "\"";
json = json + ",\"" + Convert.ToString(rs["price"]) + "\"";
json = json + ",\"" + Convert.ToString(rs["toc"]) + "\"]";
json = json + "}";
rc=true;
}
json = json +"]\n";
json = json +"}";
HttpContext.Current.Response.Write(json);
这是我的 .aspx 代码..
var jason;
$(document).ready(function() {
{
var URL='getGriddahico.ashx';
$.ajax({
url:URL,
type:'GET',
//datatype:'jason',
success: function (data) {
jason = data;
// alert(jason);
}
});
}
});
但是在警报框中,我收到了以下数据字段...
{
"page":"-2147483648",
"total":-2147483648,
"records":150508,
"rows":[]
}