Technology realization of non-refreshing chat room

Source: Internet
Author: User
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 ()



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.