ext的ajax写法,ExtJs的Ajax示例
ExtJs對于Ajax的使用非常簡單,看下面的代碼:
1.Html頁:html?PUBLIC?"-//W3C//DTD?XHTML?1.0?Transitional//EN"?"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Ext.onReady(function()?{
var?fnAjaxDemo?=?function()?{
var?mydata;
Ext.Ajax.request({
url:?"GetData.ashx?name="?+?encodeURIComponent(Ext.get("name").dom.value),?//服務器端地址
success:?function(request)?{
mydata?=?request.responseText;?//服務器端文本數據
Ext.MessageBox.alert("返回值",mydata);
},
failure:?function()?{
alert("failure!");
}
});
}
Ext.get("btnTest").on("click",?fnAjaxDemo);
})
獲取服務端信息
2.服務端GetData.ashxusing?System.Web;
using?System.Web.Services;
namespace?Ajax_WCF
{
///?
///?codebehindclassname?的摘要說明
///?
[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;
}
}
}
}
總結
以上是生活随笔為你收集整理的ext的ajax写法,ExtJs的Ajax示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用于地址解析的协议是服务器,tcp/ip
- 下一篇: .net ajax 怎么写,.NET学习