Ajax.html 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-Ajax'>/**
  19. </span> * @class Ext.Ajax
  20. * @singleton
  21. * @markdown
  22. A singleton instance of an {@link Ext.data.Connection}. This class
  23. is used to communicate with your server side code. It can be used as follows:
  24. Ext.Ajax.request({
  25. url: 'page.php',
  26. params: {
  27. id: 1
  28. },
  29. success: function(response){
  30. var text = response.responseText;
  31. // process server response here
  32. }
  33. });
  34. Default options for all requests can be set by changing a property on the Ext.Ajax class:
  35. Ext.Ajax.timeout = 60000; // 60 seconds
  36. Any options specified in the request method for the Ajax request will override any
  37. defaults set on the Ext.Ajax class. In the code sample below, the timeout for the
  38. request will be 60 seconds.
  39. Ext.Ajax.timeout = 120000; // 120 seconds
  40. Ext.Ajax.request({
  41. url: 'page.aspx',
  42. timeout: 60000
  43. });
  44. In general, this class will be used for all Ajax requests in your application.
  45. The main reason for creating a separate {@link Ext.data.Connection} is for a
  46. series of requests that share common settings that are different to all other
  47. requests in the application.
  48. */
  49. Ext.define('Ext.Ajax', {
  50. extend: 'Ext.data.Connection',
  51. singleton: true,
  52. <span id='Ext-Ajax-cfg-extraParams'> /**
  53. </span> * @cfg {Object} extraParams @hide
  54. */
  55. <span id='Ext-Ajax-cfg-defaultHeaders'> /**
  56. </span> * @cfg {Object} defaultHeaders @hide
  57. */
  58. <span id='Ext-Ajax-cfg-method'> /**
  59. </span> * @cfg {String} method @hide
  60. */
  61. <span id='Ext-Ajax-cfg-timeout'> /**
  62. </span> * @cfg {Number} timeout @hide
  63. */
  64. <span id='Ext-Ajax-cfg-autoAbort'> /**
  65. </span> * @cfg {Boolean} autoAbort @hide
  66. */
  67. <span id='Ext-Ajax-cfg-disableCaching'> /**
  68. </span> * @cfg {Boolean} disableCaching @hide
  69. */
  70. <span id='Ext-Ajax-property-disableCaching'> /**
  71. </span> * @property {Boolean} disableCaching
  72. * True to add a unique cache-buster param to GET requests. Defaults to true.
  73. */
  74. <span id='Ext-Ajax-property-url'> /**
  75. </span> * @property {String} url
  76. * The default URL to be used for requests to the server.
  77. * If the server receives all requests through one URL, setting this once is easier than
  78. * entering it on every request.
  79. */
  80. <span id='Ext-Ajax-property-extraParams'> /**
  81. </span> * @property {Object} extraParams
  82. * An object containing properties which are used as extra parameters to each request made
  83. * by this object. Session information and other data that you need
  84. * to pass with each request are commonly put here.
  85. */
  86. <span id='Ext-Ajax-property-defaultHeaders'> /**
  87. </span> * @property {Object} defaultHeaders
  88. * An object containing request headers which are added to each request made by this object.
  89. */
  90. <span id='Ext-Ajax-property-method'> /**
  91. </span> * @property {String} method
  92. * The default HTTP method to be used for requests. Note that this is case-sensitive and
  93. * should be all caps (if not set but params are present will use
  94. * &lt;tt&gt;&quot;POST&quot;&lt;/tt&gt;, otherwise will use &lt;tt&gt;&quot;GET&quot;&lt;/tt&gt;.)
  95. */
  96. <span id='Ext-Ajax-property-timeout'> /**
  97. </span> * @property {Number} timeout
  98. * The timeout in milliseconds to be used for requests. Defaults to 30000.
  99. */
  100. <span id='Ext-Ajax-property-autoAbort'> /**
  101. </span> * @property {Boolean} autoAbort
  102. * Whether a new request should abort any pending requests.
  103. */
  104. autoAbort : false
  105. });
  106. </pre>
  107. </body>
  108. </html>