EXTJS 同步和异步请求

同步方式请求:

  1. var conn = Ext.lib.Ajax.getConnectionObject().conn;
  2. conn.open("GET"'your url',false);
  3. conn.send(null);
  4. alert(conn.responseText);

或者

  1. var conn = Ext.lib.Ajax.getConnectionObject().conn;
  2. conn.open("POST", url, false);
  3. conn.send("发送到服务器端的信息");
  4. data = conn.responseText;
  5. alert(data);

关键是要设置false这个参数

异步方式请求:

  1. Ext.Ajax.request({
  2.                         url : 'listpublishersms.action',
  3.                         success : function(response, options) {
  4.                             var temp = "<chart caption='"
  5.                             + startField.getValue().dateFormat("Y-m-d")
  6.                             + "至"
  7.                             + endField.getValue().dateFormat("Y-m-d")
  8.                             + "' baseFontSize='12' formatNumberScale='0' showBorder='1'>";
  9.                             var responseArray = Ext.util.JSON
  10.                                     .decode(response.responseText);
  11.                             alert(responseArray.list.length);
  12.                             for (var i = 0;i < responseArray.list.length ;i++) {
  13.                                        var pname = responseArray.list[i].pname;
  14.                                         var count = responseArray.list[i].count;
  15.                                         temp += "<set label='" + pname
  16.                                             + "' value='" + count + "'/>";
  17.                             }
  18.                             temp += "</chart>";
  19.                             chart_chart.setDataXML(temp);
  20.                         }
  21.                     }); 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值