1.//异步ajax调用
2./**
3. * 异步调用ajax,成功后返回值,作为回调函数的参数 调用失败会提示
4. *
5. * @param {}
6. * urlStr
7. * @param {}
8. * paramsObj
9. * @param {}
10. * callbackFunc
11. */
12.function ajaxCall(urlStr, paramsObj, callbackFunc) {
13. Ext.Ajax.request({
14. url : urlStr,
15. params : paramsObj,
16. method : 'POST',
17. success : function(response) {
18. if (callbackFunc) {
19. var result = Ext.util.JSON
20. .decode(response.responseText);
21. var cbfn = callbackFunc.createCallback(result);
22. cbfn();
23. }
24. },
25. failure : function() {
26. Ext.Msg.alert("提示", "方法调用失败");
27. }
28. });
29.}
30.//同步ajax调用
31./**
32. * 同步ajax调用 返回json Object
33. *
34. * @param {}
35. * urlStr
36. * @param {}
37. * paramsStr 为字符串键值对形式“key=value&key2=value2”
38. * @return {} 返回json Object
39. */
40.function ajaxSyncCall(urlStr, paramsStr) {
41. var obj;
42. var value;
43. if (window.ActiveXObject) {
44. obj = new ActiveXObject('Microsoft.XMLHTTP');
45. } else if (window.XMLHttpRequest) {
46. obj = new XMLHttpRequest();
47. }
48. obj.open('POST', urlStr, false);
49. obj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
50. obj.send(paramsStr);
51. var result = Ext.util.JSON.decode(obj.responseText);
52. return result;
53.}