日期:2014-05-16 浏览次数:20588 次
$("#btn1").bind("click", function () {
$.ajax({
type: "POST",
// dataType: "text",
async: false,
cache: false,
url: "/AdminLogin/NewsAddHandler.ashx?op=PageStartLoading&todo=LoadingList",
success: function (data) {
alert(data);
if (data == "a") {
alert("数据库查询成功");
} else if (data == 0) {
alert("数据库查询不成功")
} else {
alert("都没有什么");
}
}
});
});
public class NewsAddHandler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
string Operation = context.Request.Form["op"];
if ("PageStartLoading".Equals(Operation))
{
string ToDo = context.Request.Form["do"];
if ("LoadingList".Equals(ToDo)) {
//开始取出NewsList里面已有数据
string ListSql = "select * from NewsList where delsign=1";
DataSet ListDS = manager.connstr.DataAdapter(ListSql);
if (ListDS.Tables.Count > 0)
{
string ListJson = FormatToJson.ToJson(ListDS);
context.Response.Clear();
context.Response.Write(1);
&nbs