[asp]代码库
//异步获取数据
var tpAction=action+'getSearch.ashx?key='+encodeURIComponent('中国');
$.getJSON(tpAction,function(rsp){//请求成功
if(rsp.status=='1'){
var list=rsp.item;
var len=list.length;
if(len==0){
//没有数据直接返回
setNull();
return;
}
//组装数据
var s=zy_tmpl(templ,list,len);
$list.append(s);
}else{
alert('','加载数据失败,请重试','确定');
}
},'json',function(err){//请求失败
alert('','加载失败,请检查网络设置!','确定');
},'POST','');
string keyy = context.Request["key"];
if (keyy != null)
{
string key = HttpUtility.UrlDecode(context.Request["key"].ToString());
//string key = context.Server.HtmlDecode(context.Request.Params["key"].ToString());
string log = "getSearch.ashx?key=" + key;
string logsql = "insert into logs(createtime,contents) values('" + DateTime.Now.ToString() + "','" + log + "')";
Sqlbase.ExecuteNonQuery(CommandType.Text, logsql, null);
//more
string sql = "select * from news where title like '%" + key + "%' order by id desc";
DataTable dt = Sqlbase.ExecuteTable(CommandType.Text, sql, null);
result rs = new result();
rs.status = 1;
rs.msg = "成功";
rs.item = dt;
string strJson = Newtonsoft.Json.JsonConvert.SerializeObject(rs);
context.Response.Clear();
context.Response.ContentEncoding = Encoding.UTF8;
context.Response.ContentType = "application/json";
context.Response.Write(strJson);
context.Response.Flush();
context.Response.End();
}
by: 发表于:2017-10-31 11:01:32 顶(0) | 踩(0) 回复
??
回复评论