HttpProxy-min.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Ext JS Library 2.0 Copyright(c) 2006-2007, Ext JS, LLC. licensing@extjs.com
  3. *
  4. * http://extjs.com/license
  5. */
  6. Ext.data.HttpProxy = function(A) {
  7. Ext.data.HttpProxy.superclass.constructor.call(this);
  8. this.conn = A;
  9. this.useAjax = !A || !A.events
  10. };
  11. Ext.extend(Ext.data.HttpProxy, Ext.data.DataProxy, {
  12. getConnection : function() {
  13. return this.useAjax ? Ext.Ajax : this.conn
  14. },
  15. load : function(E, B, F, C, A) {
  16. if (this.fireEvent("beforeload", this, E) !== false) {
  17. var D = {
  18. params : E || {},
  19. request : {
  20. callback : F,
  21. scope : C,
  22. arg : A
  23. },
  24. reader : B,
  25. callback : this.loadResponse,
  26. scope : this
  27. };
  28. if (this.useAjax) {
  29. Ext.applyIf(D, this.conn);
  30. if (this.activeRequest) {
  31. Ext.Ajax.abort(this.activeRequest)
  32. }
  33. this.activeRequest = Ext.Ajax.request(D)
  34. } else {
  35. this.conn.request(D)
  36. }
  37. } else {
  38. F.call(C || this, null, A, false)
  39. }
  40. },
  41. loadResponse : function(E, D, B) {
  42. delete this.activeRequest;
  43. if (!D) {
  44. this.fireEvent("loadexception", this, E, B);
  45. E.request.callback.call(E.request.scope, null,
  46. E.request.arg, false);
  47. return
  48. }
  49. var A;
  50. try {
  51. A = E.reader.read(B)
  52. } catch (C) {
  53. this.fireEvent("loadexception", this, E, B, C);
  54. E.request.callback.call(E.request.scope, null,
  55. E.request.arg, false);
  56. return
  57. }
  58. this.fireEvent("load", this, E, E.request.arg);
  59. E.request.callback
  60. .call(E.request.scope, A, E.request.arg, true)
  61. },
  62. update : function(A) {
  63. },
  64. updateResponse : function(A) {
  65. }
  66. });