Atlas is an Ajax Toolkit provided by Microsoft. It encapsulates the java scripts required for Ajax implementation. It is very simple to use and can directly call the Web service method, then we call back the client script through asynchronous call. I used Atlas to write a simple Ajax-based non-refreshing chatroom:
Atlas chatroom
Http://www.worong.com/atlaschat/
To reference the web service, add the following client script to the page:
< Script Language = " Javascript " SRC = " Chatservice. asmx/JS " />
The call to display and add a message is as follows. Three parameters are required for each method call: the parameters of the web service method, the callback function after successful calls, And the callback function that calls timeout.
Function Getmsg () {
Atlschat. chatservice. getconversation (
"" , // Params
Oncomplete, // Complete Event
Ontimeout // Timeout event
);
Return False ;
}
Function Add () {
Document. getelementbyid ('info'). innerhtml = ' < SPAN Style = " Background-color: Yellow " > & Nbsp; posting & Nbsp; </ Span > ';
Atlschat. chatservice. Add (
Document. getelementbyid ('inputname'). value. Replace ('\ t ',' & Nbsp; & Nbsp; & Nbsp ;') + '\ T' + Document. getelementbyid ('inputmsg '). value. Replace (' \ t ',' & Nbsp; & Nbsp; & Nbsp ;'),
Getmsg,
Ontimeout
);
Return False ;
}
Function Oncomplete (result)
{
Document. getelementbyid ('msg '). innerhtml=Result;
Document. getelementbyid ('info'). innerhtml= "";
}
Function Ontimeout (result)
{
Document. getelementbyid ('info'). innerhtml= "Time out";
}
Finally, you need to reference several JS files provided by Atlas on the page:
< Atlas: script ID = " Script1 " Runat = " Server " Path = " ~ /Scriptlibrary/atlascompat. js " Browser = " Mozilla " />
< Atlas: script ID = " Script2 " Runat = " Server " Path = " ~ /Scriptlibrary/atlascompat. js " Browser = " Firefox " />
< Atlas: script ID = " Script3 " Runat = " Server " Path = " ~ /Scriptlibrary/atlascompat. js " Browser = " Applemac-Safari " />
< Atlas: script ID = " Script4 " Runat = " Server " Path = " ~ /Scriptlibrary/atlascore. js " />
< Atlas: script ID = " Script5 " Runat = " Server " Path = " ~ /Scriptlibrary/atlascompat2.js " Browser = " Applemac-Safari " />
< Script Type = " Text/XML-script " >
< Page xmlns: script = " Http://schemas.microsoft.com/xml-script/2005 " >
< References >
<! -- Repath the following SRC attributes, using regular client relative paths as necessary -->
< Add SRC = " Scriptlibrary/atlasui. js " />
< Add SRC = " Scriptlibrary/atlascontrols. js " />
</ References >
< Components >
</ Components >
</ Page >
</ Script >
Is the official website of Atlas http://beta.asp.net/default.aspx? Tabindex = 7 & Tabid = 47. Although it provides support for non-ie browsers, updating the DIV in Firefox will refresh the page and won't work on Mac safari.