Extjs is very simple to use Ajax. See the following code:
1. html page:
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<LINK rel = "stylesheet" type = "text/CSS" href = "JS/ext2.2/resources/CSS/ext-all.css"/>
<SCRIPT type = "text/JavaScript" src = "JS/ext2.2/adapter/EXT/ext-base.js"> </SCRIPT>
<SCRIPT type = "text/JavaScript" src = "JS/ext2.2/ext-all.js"> </SCRIPT>
<Title> </title>
</Head>
<Body>
<SCRIPT type = "text/JavaScript">
Ext. onready (function (){
VaR fnajaxdemo = function (){
VaR mydata;
Ext. Ajax. Request ({
URL: "getdata. ashx? Name = "+ encodeuricomponent (ext. Get (" name "). Dom. value), // server address
Success: function (request ){
Mydata = request. responsetext; // server-side text data
Ext. MessageBox. Alert ("return value", mydata );
},
Failure: function (){
Alert ("failure! ");
}
});
}
Ext. Get ("btntest"). On ("click", fnajaxdemo );
})
</SCRIPT>
<Input id = "name" value = "Jimmy" name = "name"/>
<Button id = "btntest"> Get Server Information </button>
</Body>
</Html>
2. Server getdata. ashx Using system. Web;
Using system. Web. Services;
Namespace ajax_wcf
{
/// <Summary>
/// $ Codebehindclassname $ abstract description
/// </Summary>
[WebService (namespace = "http://tempuri.org/")]
[Webservicebinding (conformsto = wsiprofiles. basicprofile1_1)]
Public class getdata: ihttphandler
{
Public void processrequest (httpcontext context)
{
Context. response. contenttype = "text/plain ";
If (context. request ["name"]! = NULL & context. request ["name"]. tostring ()! = "")
{
Context. response. Write ("Hello World," + context. request ["name"]. tostring () + "! ");
}
Else
{
Context. response. Write ("Hello World ");
}
}
Public bool isreusable
{
Get
{
Return false;
}
}
}
}
Running effect:
Please indicate from "Yang Guo under the bodhi tree" http://www.cnblogs.com/yjmyzz/archive/2008/08/30/1279918.html