Ajax已经听说了很长时间了,一致没有使用,感觉应该是不错的。今天作了一个简单的测试,嘿嘿,还不错!

 

Ajax.js

// JavaScript Document

 var xmlHttp;
 var TagsId="body";
 
 function CreateXmlHttp(){
  if(window.ActiveXObject){
   xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); 
  }
  else if (window.XMLHTTPRequest){
   xmlHttp=new XMLHTTPRequest();
  }
 }
 
 function getTextXmlData(url){
  CreateXmlHttp();
  xmlHttp.onreadystatechange=HandleStateChanged;
  xmlHttp.open("get",url,false); //第三个参数boolean asynch表示异步否
  xmlHttp.send(null);
 }
 
 function HandleStateChanged(){
  var msg;
  if(xmlHttp.readyState==4){
   if(xmlHttp.status==200){
    msg=xmlHttp.responseText;
   }
   else{
    msg="发生错误:<br/>错误状态 " + xmlHttp.status;
   }
  }else{
   switch(xmlHttp.readystate)
   {
    case 0:
     //对象已建立,但是尚未初始化(尚未调用open方法)
     msg="初始化对象...";
     break; 
    case 1:
     //对象已建立,尚未调用send方法
     msg="正在尝试服务器连接...";
     break;
    case 2:
     //send方法已调用,但是当前的状态及http头未知
     msg="服务器连接成功。";
     break;
    case 3:
     //已接收部分数据
     //因为响应及http头不全,
     //这时通过responseBody和responseText获取部分数据会出现错误,
     msg="";
     break;
    default:
     msg="未知状态!";break;
   }
  }
  document.getElementById(TagsId).innerHTML=msg;
 }

Admin_edit.asp

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><%= SiteName %>新闻添加/修改</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="Style/MainStyle.css" _fcksavedurl=""Style/MainStyle.css"" _fcksavedurl=""Style/MainStyle.css"" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
 background-color: #799AE1;
 font-size:12px;
}
.style1 {
 font-color:#799ae1;
 font-weight: bold;
 font-size: 18px;
}
.style2 {color: #FF0000}
.style4 {color: #FF0000; font-weight: bold; }
.style5 {color: #FFFFFF}
.tableBorder {
 BORDER-RIGHT: #183789 1px solid; BORDER-TOP: #183789 1px solid; BORDER-LEFT: #183789 1px solid; WIDTH: 98%; BORDER-BOTTOM: #183789 1px solid; BACKGROUND-COLOR: #ffffff
}
.input1 {
 font-family: "宋体";
 font-size: 12px;
 text-decoration: none;
 height: 18px;
 width: 35px;
 border: thin inset;
}

-->
</style>
<script type="text/javascript" src="Script/Ajax.js"></script>
<script type="text/javascript" language="javascript1.1">
 TagsId="msg";
</script>
<%
 dim page
 page=trim(request.QueryString("page"))
 if page="" then
  page=1
 end if
%>
</head>

<body onLoad="getTextXmlData('ajax_admin_editnews.asp?parent=admin_managenews.asp&page=<%=page%>')">
<!--#include file="Admin_TopHeader.asp" -->
<div ></div>
</body>
</html>

Ajax_admin_editnews.asp

<!--#include file="Common/webconfig.asp" -->
<!--#include file="Common/clsmain.asp" -->

<%
 If Session("User")="" Then
  Session.Abandon()
  Response.Clear()
  Response.Redirect("admin_login.asp")
  Response.End()
 Else
  Dim dsj
  Set dsj=New clsDSJ
  IF NOT dsj.Debug Then ON ERROR RESUME NEXT
  dsj.ClientConnected
  'If NOT dsj.ChkPost Then dsj.alert("请不要从外部提交数据"):REsponse.Flush():Response.End()
  
  call listnews()
  
   Set dsj=Nothing
 end if
 %>

<%sub listnews()%>
<%
  Dim NewsId
  NewsId=Trim(Request.Form("frmNewsid"))
  
  dsj.chkInvStr(newsid)
  If dsj.Error=1982 then
   response.Clear()
   Response.Write ("Hacker is not good.<br>AloneSword.")
  End If
  
  dsj.ConnectionDataBase dsj.Database,dsj.dbUserId,dsj.dbPassword,dsj.dbType
  Dim strSQL,objRs
  Set objRs=Server.CreateObject("ADODB.RecordSet")
%>
 <form name="form1" method="post" action="">
  <table width="98%"  border="0" align="center" cellpadding="3" cellspacing="1" class="tableBorder">
    <tr bordercolor="#5E78D5">
      <td colspan="5" bordercolor="#5E78D5" bgcolor="#5E78D5"><div align="center" class="style1 style5"><%= Sitename %>新闻管理</div></td>
    </tr>
    <tr bordercolor="#FFFFFF" bgcolor="#F5F5F5">
      <td colspan="5"><div align="center">
        <%
 If newsid<>"" Then
  strSQL="UPDATE dsj_news SET DelDate='"& Now() &"',WhoDel='"& Session("User") &"',IsDeleted=true,IP='"&dsj.GetIP&"' WHERE news>CopyRight &copy; 2005 BY:<%= SiteName %>&nbsp;&nbsp;.&nbsp;&nbsp;All Rights Reserved.&nbsp;&nbsp;Designer:孤剑&nbsp;&nbsp;Version:<%=dsj.Version%></span></td>
    </tr>
  </table>
</form>
<%end sub%>

<%sub DivPage(objrsCurrentPage,objrsPageCount,objrsPageSize,objrsRecordCount)%>
<style>
 #dvpage {
 border-top: 1px dashed #000000;
}
</style>
 <div align="center" >尾页</a> &nbsp;&nbsp;&nbsp;&nbsp;
 每页<%=objrsPageSize%>条 / 总共 <%=objrsRecordCount%> 条&nbsp;&nbsp;&nbsp;&nbsp;
 当前页: <%=objrsCurrentPage%> &nbsp;&nbsp;总页数: <%=objrsPageCount%>
</div>
<%end sub%>

相关文章:

  • 2021-12-14
  • 2022-01-10
  • 2021-08-21
  • 2021-05-19
猜你喜欢
  • 2022-01-03
  • 2021-06-22
  • 2022-01-21
  • 2021-09-28
  • 2022-12-23
  • 2021-04-03
  • 2021-10-15
相关资源
相似解决方案