Joson请求后台数据维护
A.前台页面设计
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>频道管理</title>
<script type="text/javascript" src="../JS/jquery-1.4.1.min.js"></script>
<script type="text/javascript" src="../Common/Page.js"></script>
<link href="../Admin_Style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../JS/jquery-impromptu.3.1.min.js"></script>
<link href="../Css/alert.css" rel="stylesheet" type="text/css" />
<link href="../Css/dialog.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../JS/dialog.js"></script>
<script src="../JS/Cookies.js" type="text/javascript"></script>
<script src="../JS/CheckLogin.js" type="text/javascript"></script>
<script src="../Common/GetRequestUrl.js" type="text/javascript"></script>
</head>
<body>
<form id="form1" runat="server">
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="border" style="margin-bottom: 10px;">
<tr>
<td height="25" align="center" class="topbg">
频道管理
</td>
</tr>
<tr>
<td height="25" class="bgcolor">
<label for="txtKeyWord">
</label>
按频道名:
<input name="txtKeyWord" type="text" class="border" id="txtKeyWord" />
<input name="button" type="button" class="anniucss002" id="webSearch" value="快速查询" />
<input name="button" type="button" class="anniucss002" style="display:none" id="btnAdd" value="添加频道" οnclick="javascript:location.href='ChannelAdd.htm'" />
【<a href="javascript:showHideSearch()">显示高级搜索</a>】
</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="border" style="margin-bottom: 10px;
display: none;" id="SearchAreaHtml">
<tr>
<td height="30" class="bgcolor">
</td>
</tr>
</table>
<div id="showPageRecord" style="width: 100%;">
</div>
</form>
</body>
</html>
<script type="text/javascript">
CheckLogin("../");
var navid = GetRequestName("navid");
if (navid != "")
SetCookie("navid", navid);
url = "../Json/ChannelHandler.ashx?type=GetAll&page=";
nameArr = ['频道名称', '添加时间'];
lenArr = ['40%', '20%'];
jsonNameArr = ['ChannelName', 'AddTime'];
clickrow = [0, 0];
coldisplay = 10; //按钮样式为,删除,修改,添加版块
isShowCheck = 1;
pageinit();
$("#webSearch").click(function() {
url = "../Json/ChannelHandler.ashx?type=GetAll&ChannelName=" + escape($("#txtKeyWord").val()) + "&page=";
pageinit();
})
//修改操作
reEdit = function(id) {
window.location.href = "ChannelUpd.htm?nid=" + id;
}
//删除操作
var nid;
reDelete = function(id) {
nid = id;
$.prompt('确定要删除您所选的记录吗?本操作将无法恢复!', '系统提示', 1, { buttons: { '确定': true, '取消': false }, callback: mycallbackfunc });
}
deleteSel = function() {
var selID = selIdList();
if (selID == "") {
$.prompt('至少选择一项!', '系统提示', 4, { buttons: { '确定': true} });
} else {
reDelete(selID.substr(0, selID.length - 1));
}
}
function mycallbackfunc(v, m, f) {
if (v == true) {
$.post("../Json/ChannelHandler.ashx", { 'type': "ChannelDel", 'id': Math.random(), 'ChannelId': nid }, function(data) {
var data1 = eval("(" + data + ")");
if (data1.data[0]["Result"] == "1") {
$.prompt('频道信息删除成功!', '系统提示', 3);
location.href = "ChannelList.htm";
} else {
$.prompt('频道信息删除失败!', '系统提示', 4);
}
}, "Json");
}
}
//添加版块操作
reChannelPlateAdd = function(cid) {
location.href = "../ChannelPlate/ChannelPlateAdd.htm?ChannelId="+cid+"&id=" + Math.random() + "";
}
reSeeNav=function(cid)
{
location.href = "../ChannelPlate/ChannelPlateList.htm?ChannelId="+cid+"&id=" + Math.random() + "";
}
//显示高级搜索区域
showHideSearch = function() {
$("#SearchAreaHtml").slideToggle("hide");
}
</script>
B。Joson数据处理(ChannelHandler.ashx)
<%@ WebHandler Language="C#" Class="ChannelHandler" %>
using System;
using System.Web;
using Dal;
using Model;
public class ChannelHandler : IHttpHandler {
ChannelDal advbll = new ChannelDal();
public void ProcessRequest (HttpContext context) {
string type = context.Request["type"].ToString();
switch (type)
{
case "ChannelAdd":
context.Response.Write(ChannelAdd()); break;
case "GetAll":
context.Response.Write(GetChannel()); break;
case "ChannelDel":
context.Response.Write(ChannelDel()); break;
case "ChannelBind":
context.Response.Write(ChannelBind()); break;
case "ChannelUpd":
context.Response.Write(ChannelUpd()); break;
case "ChannelIsUseful":
context.Response.Write(ChannelIsUseFul()); break;
case"GetAllChannel":
context.Response.Write(advbll.GetAllChannel());
break;
default: break;
}
}
public string ChannelIsUseFul()
{
SQLHelper.JsonHelper json = new SQLHelper.JsonHelper();
ChannelModel model = new ChannelModel();
try
{
int channeid = int.Parse(HttpContext.Current.Request["ChannelId"].ToString().Trim());
string strName=advbll.Exists(channeid);
if (!string.IsNullOrEmpty(strName))
{
json.AddItem("Result", "1");
json.AddItem("name",strName);
json.ItemOk();
}
else
{
json.AddItem("Result", "-1");
json.ItemOk();
}
}
catch (Exception ex)
{
json.AddItem("Result", ex.Message.ToString());
json.ItemOk();
}
return json.ToString();
}
public string ChannelUpd()
{
SQLHelper.JsonHelper json = new SQLHelper.JsonHelper();
ChannelModel model = new ChannelModel();
try
{
model.Id = int.Parse(HttpContext.Current.Request["nid"].ToString().Trim());
model.ChannelName = HttpContext.Current.Server.UrlDecode(HttpContext.Current.Request["ChannelName"].ToString());
model.ChannelTitle = HttpContext.Current.Server.UrlDecode(HttpContext.Current.Request["ChannelTitle"].ToString());
model.ChannelKeyWords = HttpContext.Current.Server.UrlDecode(HttpContext.Current.Request["ChannelKeyWords"].ToString());
model.ChannelDesContent = HttpContext.Current.Server.UrlDecode(HttpContext.Current.Request["ChannelDesContent"].ToString());
model.AddTime = DateTime.Now;
if (advbll.UpdateChannel(model))
{
PublicClass.AddLog("修改了名为【"+model.ChannelName+"】的频道信息!");
json.AddItem("Result", "1");
json.ItemOk();
}
else
{
json.AddItem("Result", "-1");
json.ItemOk();
}
}
catch (Exception ex)
{
json.AddItem("Result", ex.Message.ToString());
json.ItemOk();
}
return json.ToString();
}
public string ChannelBind()
{
string StrWhere = "1=1";
if (!string.IsNullOrEmpty(HttpContext.Current.Request["nid"]))
{
StrWhere += " and id=" + HttpContext.Current.Request["nid"].ToString().Trim() + "";
}
else
{
StrWhere += " and 1=2";
}
PagerModel model = new PagerModel();
model.Page_Index = 1;
model.Page_Size = 20;
model.Find_RecordList = "";
model.Filter_Condition = StrWhere;
model.Record_Count = 0;
model.Sign_Record = "Id";
model.TableName = "C_Channel";
model.Taxis_Sign = 1;
model.TaxisField = "AddTime";
return advbll.GetChannelJson(model);
}
public string ChannelDel()
{
SQLHelper.JsonHelper json = new SQLHelper.JsonHelper();
try
{
if (advbll.DeleteChannel(HttpContext.Current.Request["ChannelId"].ToString()))
{
json.AddItem("Result", "1");
json.ItemOk();
}
else
{
json.AddItem("Result", "-1");
json.ItemOk();
}
}
catch (Exception ex)
{
json.AddItem("Result", ex.Message.ToString());
json.ItemOk();
}
return json.ToString();
}
public string GetChannel()
{
string StrWhere = "1=1";
if (!string.IsNullOrEmpty(HttpContext.Current.Request["ChannelName"]))
{
StrWhere += " and ChannelName like '%" + HttpContext.Current.Server.UrlDecode(HttpContext.Current.Request["ChannelName"].ToString().Trim()) + "%'";
}
PagerModel model = new PagerModel();
model.Page_Index = int.Parse(HttpContext.Current.Request["page"]) == 0 ? 1 : int.Parse(HttpContext.Current.Request["page"]);
model.Page_Size = 20;
model.Find_RecordList = "";
model.Filter_Condition = StrWhere;
model.Record_Count = 0;
model.Sign_Record = "Id";
model.TableName = "C_Channel";
model.Taxis_Sign = 0;
model.TaxisField = "AddTime";
return advbll.GetChannelJson(model);
}
public string ChannelAdd()
{
SQLHelper.JsonHelper json = new SQLHelper.JsonHelper();
ChannelModel model = new ChannelModel();
try
{
model.ChannelName = HttpContext.Current.Server.UrlDecode(HttpContext.Current.Request["ChannelName"].ToString());
model.ChannelTitle = HttpContext.Current.Server.UrlDecode(HttpContext.Current.Request["ChannelTitle"].ToString());
model.ChannelKeyWords = HttpContext.Current.Server.UrlDecode(HttpContext.Current.Request["ChannelKeyWords"].ToString());
model.ChannelDesContent = HttpContext.Current.Server.UrlDecode(HttpContext.Current.Request["ChannelDesContent"].ToString());
model.AddTime = DateTime.Now;
if (advbll.AddChannel(model))
{
PublicClass.AddLog("添加了一条名为【" + model.ChannelName + "】的频道信息!");
json.AddItem("Result", "1");
json.ItemOk();
}
else
{
json.AddItem("Result", "-1");
json.ItemOk();
}
}
catch (Exception ex)
{
json.AddItem("Result", ex.Message.ToString());
json.ItemOk();
}
return json.ToString();
}
public bool IsReusable {
get {
return false;
}
}
}
Joson请求后台数据维护相关推荐
- 进一步封装axios并调用其读取数据(吐槽~在安卓9.0以下或者IOS10.X以下手机端H5页面不支持,在这两种情况下的系统只能使用ajax或者原生js请求后台数据)
注意!!!(修改于2020年7月18日) 在安卓9.0以下或者IOS10.X以下手机端H5页面不支持,在这两种情况下的系统只能使用ajax或者原生js请求后台数据 报错截图如下 报错内容: {&quo ...
- jquery中ajax请求后台数据成功后既不执行success也不执行error解决方法
jquery中ajax请求后台数据成功后既不执行success也不执行error解决方法 参考文章: (1)jquery中ajax请求后台数据成功后既不执行success也不执行error解决方法 ( ...
- ajax 请求成功 再执行javascript,jquery中ajax请求后台数据成功后既不执行success也不执行error的完美解决方法...
jquery中ajax请求后台数据成功后既不执行success也不执行error,此外系统报错:Uncaught SyntaxError: Unexpected identifier at Objec ...
- 调用$.ajax不成功,jquery中ajax请求后台数据成功后既不执行success也不执行error的完美解决方法...
jquery中ajax请求后台数据成功后既不执行success也不执行error,此外系统报错:Uncaught SyntaxError: Unexpected identifier at Objec ...
- JS 操作 HTML 和 AJAX 请求后台数据
为某个元素插入值,添加属性,添加子元素 1 <div class="col-sm-6"> 2 <select class="form-control&q ...
- 微信小程序开发工具能正常请求后台数据,手机预览请求失败
微信小程序开发工具能正常请求后台数据,手机预览请求失败 问题描述 微信开发者工具调试完想用手机预览效果,结果发现凡是后台请求都失败. 原因分析 可能的原因有三个: 微信开发者工具详情里的本地设置,没有 ...
- Vue 利用axios请求后台数据
说明:前后端代码不在同一个电脑上 后端接口地址: http://ip:8888/Xqy/user/queryUser?name=xqy 一:准备工作 导包: npm i axios 安装其他插件的时候 ...
- c# webform ajax操作,C# WebForm开发 前台请求后台数据的方法总结
说到前台请求后台数据,我们一般都是用到AJAX(异步JavaScript和XML) .AJAX 通过在后台与服务器进行少量数据交换,AJAX 可以使网页实现异步更新.这意味着可以在不重新加载整个网页的 ...
- vue使用ajax提交数据,vue使用ajax请求后台数据的方法
vue使用ajax请求后台数据的方法 发布时间:2020-10-15 16:54:41 来源:亿速云 阅读:108 作者:栢白 这篇文章主要介绍了vue使用ajax请求后台数据的方法,具有一定借鉴价值 ...
- 前端写接口 请求后台数据 存vuex中 打印到控制台
最近从B站上面跟着敲 vue 的项目,多次看到有关于前台拿到后端的接口地址文档,写前端接口,然后请求后台数据,放到 vuex 当中,再然后再在需要展示数据时渲染出来,于是做个输出小结,分享出来,供大家 ...
最新文章
- 桥牌笔记:当其它希望不存在时,才进行飞张
- 《Dreamweaver CS6完美网页制作——基础、实例与技巧从入门到精通》——1.3 常用网页设计软件...
- 为什么redis取出来是null_跳表:为什么Redis一定要用跳表来实现有序集合
- 某教授对“中国式科研”的酒后真言
- 数据结构-线性表之用队列实现栈用栈实现队列
- php preg split,php preg_split()字符串分割函数的使用方法
- 剑指offer——面试题57:删除链表中重复的结点
- linux教学之安装python与pip环境
- pytest生成测试报告
- 仿网易云手机版代码_网易uu加速器官网下载-网易uu加速器手机版下载
- Matlab求解线性规划
- 【源码分析】Spring Boot中Relaxed Binding机制的不同实现
- 计算机内存条多大容量,电脑内存条到底怎么选?选多大容量最合适?
- 六一儿童节 | TcaplusDB祝大小朋友节日快乐
- containerd
- DB2数据库配置db cfg
- Linux系统定时任务crond那些事
- 暴露在公网环境下主机的安全防护
- 都2020年了,还有必要学Arduino吗
- 51单片机串口多机通信的原理与编程实现
热门文章
- Ubuntu中修改Home目录下中文目录为英文
- Java微信公众平台开发(十一)——开发中微信公众平台/开放平台/商户平台的关联
- 计算机注销的快捷键,电脑死机了按哪个键注销电脑
- 最新的中国姓氏重新洗牌:快来看看你的姓排第几?
- html 长度太长截断,HTML CSS 表格换行禁止 超出指定长度自动截断
- 阿里巴巴-飞猪 电话面试
- 变邻域搜索(VNS)原理梳理和应用细节-附求解VRPTW问题C++代码
- wxpython 操作图片_wxpython 图像编程
- 2021-09-27 人民邮电出版社网址下获取新书推荐的所有图书名称
- 马克思主义哲学与价值哲学