Chat Room | refresh | no Refresh | chat Room | refresh | No Refresh first simple description
Service side
Generating the required XML files with the program
Client
Use XMLHTTP or DSO (note State) to refresh the required data periodically
In contrast, the DSO can be mapped into a recordset operation is relatively simple
Here's what I'm simply writing about. It's not a complete part.
It's just snippets, but as a technical reference, it's enough.
Need MSXML 4.0
Service side I wrote two constructors, which are chat content chat users, respectively.
<script language= "JScript" runat= "Server" >
function Slightboychat ()
{
This.id;
This. Xmldomelement = Server.CreateObject ("msxml2.freethreadeddomdocument.4.0")
This. ADD = function (Name, Content, Append)
{
var root = this. Xmldomelement.documentelement;
var newitem = this. Xmldomelement.createelement ("Item");
var newitemname = this. Xmldomelement.createelement ("Name");
var newitemnamevalue = this. Xmldomelement.createcdatasection (Name);
Newitemname.appendchild (Newitemnamevalue)
var newitemcontent = this. Xmldomelement.createelement ("Content");
var newitemcontentvalue = this. Xmldomelement.createcdatasection (Content);
Newitemcontent.appendchild (Newitemcontentvalue)
var newitemappend = this. Xmldomelement.createelement ("Append");
Newitemappend.text = Append;
Newitem.appendchild (Newitemname);
Newitem.appendchild (newitemcontent);
Newitem.appendchild (Newitemappend);
if (Root.childNodes.length > 10)
{
Root.removechild (Root.firstchild)
}
Root.appendchild (NewItem)
}
This. Save = function ()
{
Application ("chatcontent") = this. Xmldomelement.xml;
}
This. GUID = function (pushguid)
{
if (Pushguid.count > 0)
{
This.id = Pushguid;
}
Else
{
This.id = "";
}
}
This. XML = function ()
{
if (this.id!= "")
{
var xmldomelementstring = "<?xml version=\" 1.0\ "encoding=\" gb2312\ "?><chat>";
var items = Chat.XMLDOMElement.selectNodes ("//item[append >" + this.id + "]")
for (var item = Items.nextnode (); item; item = Items.nextnode ())
{
Xmldomelementstring + = Item.xml;
}
xmldomelementstring = "</Chat>";
if (Items.length > 0)
{
return xmldomelementstring;
}
Else
{
Return
}
}
Else
{
return this. XMLDOMElement.xml.replace ("<?xml version=\" 1.0\ "?>", "<?xml version=\" 1.0\ "encoding=\" gb2312\ "?>");
}
}
This. Load = function ()
{
if (Application ("chatcontent") = = "" | typeof (Application ("chatcontent")) = = "undefined")
{
Application ("chatcontent") = "<?xml version=\ 1.0\" encoding=\ "gb2312\"? ><chat><item><name >slightboy</Name><Content> Welcome ^^ </Content><Append> "+ New Date (). GetTime () +" </append ></Item></Chat> ";
}
This. Xmldomelement.loadxml (Application ("Chatcontent"));
}
This. Empty = function ()
{
Application ("chatcontent") = "<?xml version=\ 1.0\" encoding=\ "gb2312\"? ><chat><item><name >slightboy</Name><Content> Welcome ^^ </Content><Append> "+ New Date (). GetTime () +" </append ></Item></Chat> ";
}
This. Load ();
}
function Slightboychatlist ()
{
This. Xmldomelement = Server.CreateObject ("msxml2.freethreadeddomdocument.4.0")
This. ADD = function (Name, level)
{
var root = this. Xmldomelement.documentelement;
var newitem = this. Xmldomelement.createelement ("Item");
var newitemname = this. Xmldomelement.createelement ("Name");
var newitemnamevalue = this. Xmldomelement.createcdatasection (Name);
Newitemname.appendchild (Newitemnamevalue)
var newitemlevel = this. Xmldomelement.createelement ("level");
var newitemlevelvalue = this. Xmldomelement.createcdatasection (level);
Newitemlevel.appendchild (Newitemlevelvalue)
var newitemappend = this. Xmldomelement.createelement ("Append");
Newitemappend.text = Append;
Newitem.appendchild (Newitemname);
Newitem.appendchild (Newitemlevel);
Root.appendchild (NewItem)
}
This. Save = function ()