Connection的使用方法

ConnectionTest.html

<html>
<head>
<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../../ext-all.js"></script>
<script language="javascript" type="text/javascript">

var conn=new Ext.data.Connection({
  listeners : {
   beforerequest : function(){alert("beforeRequest")},
   requestcomplete : function(){alert("Complete Request ")},
   requestexception : function(){alert("Request Exception")}
  },
  url : "http://127.0.0.1:8080/CommonWeb/jsonData.jsp",
  timeout : 30000,
  autoAbort : false ,
  defaultHeaders : {
    "Mys'name" : "Dangzhao",
    "Mys'sex"  : "Old boy~"
   },
  disableCaching : true ,
  extraParams : {
   "Id" : "0",
   "Action" : "Insert"
  },
  method : "GET"
 });

conn.request({
  success : sucessFn,
  failure : failureFn
 });

function sucessFn(response, param ){
 alert("Sucess")
 alert(response.responseText)
 alert(param)
}
function failureFn(response, param ){
 alert("Failure")
 alert(response.responseText)
 alert(param)
}

</script>
</head>

<body>


</body>
</html>

 

jsonData.jsp

 

<%@page import="java.util.*" %>
Hi,Please replace here json or xml data
<%
Enumeration enm=request.getHeaderNames();
while(enm.hasMoreElements()){
    String key=(String)enm.nextElement();
    System.out.println(key+":"+request.getHeader(key));
}
Map p=request.getParameterMap();
Iterator it=p.keySet().iterator();
while(it.hasNext()){
    String key=(String)it.next();
    System.out.println(key+":"+((String[])p.get(key))[0]);
}
%>

 

System.out.....

Accept:*/*
Accept-Language:zh-cn
mys'name:Dangzhao
Referer:file://E:\ext-2.0.2\ext-2.0.2\examples\grid\ConnectionTest.html
x-requested-with:XMLHttpRequest
mys'sex:Old boy~
Accept-Encoding:gzip, deflate
User-Agent:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)
Host:127.0.0.1:7001
Connection:Keep-Alive
Cookie:2=1; 74=1; 145=0; 80=1; 102=1; JSESSIONID=LpJS1DHh!-1296687579
Action:Insert
_dc:1209981558125
Id:0

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值