📄 ext.data.connection.html
字号:
<p><b>Important:</b> Ajax server requests are asynchronous, and this call willreturn before the response has been received. Process any returned datain a callback function.</p><p>To execute a callback function in the correct scope, use the <tt>scope</tt> option.</p> <div class="mdetail-params"> <strong>Parameters:</strong> <ul><li><code>options</code> : Object<div class="sub-desc">An object which may contain the following properties:<ul><li><b>url</b> : String/Function (Optional)<div class="sub-desc">The URL towhich to send the request, or a function to call which returns a URL string. The scope of thefunction is specified by the <tt>scope</tt> option. Defaults to configured URL.</div></li><li><b>params</b> : Object/String/Function (Optional)<div class="sub-desc">An object containing properties which are used as parameters to therequest, a url encoded string or a function to call to get either. The scope of the functionis specified by the <tt>scope</tt> option.</div></li><li><b>method</b> : String (Optional)<div class="sub-desc">The HTTP method to usefor the request. Defaults to the configured method, or if no method was configured,"GET" if no parameters are being sent, and "POST" if parameters are being sent. Note thatthe method name is case-sensitive and should be all caps.</div></li><li><b>callback</b> : Function (Optional)<div class="sub-desc">Thefunction to be called upon receipt of the HTTP response. The callback iscalled regardless of success or failure and is passed the followingparameters:<ul><li><b>options</b> : Object<div class="sub-desc">The parameter to the request call.</div></li><li><b>success</b> : Boolean<div class="sub-desc">True if the request succeeded.</div></li><li><b>response</b> : Object<div class="sub-desc">The XMLHttpRequest object containing the response data. See <a href="http://www.w3.org/TR/XMLHttpRequest/">http://www.w3.org/TR/XMLHttpRequest/</a> for details about accessing elements of the response.</div></li></ul></div></li><a id="request-option-success"></a><li><b>success</b> : Function (Optional)<div class="sub-desc">The functionto be called upon success of the request. The callback is passed the followingparameters:<ul><li><b>response</b> : Object<div class="sub-desc">The XMLHttpRequest object containing the response data.</div></li><li><b>options</b> : Object<div class="sub-desc">The parameter to the request call.</div></li></ul></div></li><li><b>failure</b> : Function (Optional)<div class="sub-desc">The functionto be called upon failure of the request. The callback is passed thefollowing parameters:<ul><li><b>response</b> : Object<div class="sub-desc">The XMLHttpRequest object containing the response data.</div></li><li><b>options</b> : Object<div class="sub-desc">The parameter to the request call.</div></li></ul></div></li><li><b>scope</b> : Object (Optional)<div class="sub-desc">The scope inwhich to execute the callbacks: The "this" object for the callback function. If the <tt>url</tt>, or <tt>params</tt> options werespecified as functions from which to draw values, then this also serves as the scope for those function calls.Defaults to the browser window.</div></li><li><b>form</b> : Element/HTMLElement/String (Optional)<div class="sub-desc">The <tt><form></tt>Element or the id of the <tt><form></tt> to pull parameters from.</div></li><a id="request-option-isUpload"></a><li><b>isUpload</b> : Boolean (Optional)<div class="sub-desc">True if the form object is afile upload (will usually be automatically detected).<p>File uploads are not performed using normal "Ajax" techniques, that is they are <b>not</b>performed using XMLHttpRequests. Instead the form is submitted in the standard manner with theDOM <tt><form></tt> element temporarily modified to have its<a href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-target">target</a> set to referto a dynamically generated, hidden <tt><iframe></tt> which is inserted into the documentbut removed after the return data has been gathered.</p><p>The server response is parsed by the browser to create the document for the IFRAME. If theserver is using JSON to send the return object, then the<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17">Content-Type</a> headermust be set to "text/html" in order to tell the browser to insert the text unchanged into the document body.</p><p>The response text is retrieved from the document, and a fake XMLHttpRequest objectis created containing a <tt>responseText</tt> property in order to conform to therequirements of event handlers and callbacks.</p><p>Be aware that file upload packets are sent with the content type <a href="http://www.faqs.org/rfcs/rfc2388.html">multipart/form</a>and some server technologies (notably JEE) may require some custom processing in order toretrieve parameter names and parameter values from the packet content.</p></div></li><li><b>headers</b> : Object (Optional)<div class="sub-desc">Requestheaders to set for the request.</div></li><li><b>xmlData</b> : Object (Optional)<div class="sub-desc">XML documentto use for the post. Note: This will be used instead of params for the postdata. Any params will be appended to the URL.</div></li><li><b>jsonData</b> : Object/String (Optional)<div class="sub-desc">JSONdata to use as the post. Note: This will be used instead of params for the postdata. Any params will be appended to the URL.</div></li><li><b>disableCaching</b> : Boolean (Optional)<div class="sub-desc">Trueto add a unique cache-buster param to GET requests.</div></li></ul></p><p>The options object may also contain any other property which might be needed to performpostprocessing in a callback because it is passed to callback functions.</p></div></li> </ul> <strong>Returns:</strong> <ul> <li><code>Number</code><div class="sub-desc">transactionId The id of the server transaction. This may be used to cancel the request.</div></li> </ul> </div> </div> </div> </td> <td class="msource">Connection</td> </tr> <tr class="method-row inherited expandable"> <td class="micon"><a class="exi" href="#expand"> </a></td> <td class="sig"> <a id="Ext.data.Connection-resumeEvents"></a> <b>resumeEvents</b>() : void <div class="mdesc"> <div class="short">Resume firing events. (see <a ext:cls="Ext.util.Observable" ext:member="suspendEvents" href="output/Ext.util.Observable.html#suspendEvents">suspendEvents</a>)</div> <div class="long"> Resume firing events. (see <a ext:cls="Ext.util.Observable" ext:member="suspendEvents" href="output/Ext.util.Observable.html#suspendEvents">suspendEvents</a>) <div class="mdetail-params"> <strong>Parameters:</strong> <ul><li>None.</li> </ul> <strong>Returns:</strong> <ul> <li><code>void</code></li> </ul> </div> </div> </div> </td> <td class="msource"><a ext:cls="Ext.util.Observable" ext:member="#resumeEvents" href="output/Ext.util.Observable.html#resumeEvents">Observable</a></td> </tr> <tr class="method-row inherited alt expandable"> <td class="micon"><a class="exi" href="#expand"> </a></td> <td class="sig"> <a id="Ext.data.Connection-suspendEvents"></a> <b>suspendEvents</b>() : void <div class="mdesc"> <div class="short">Suspend the firing of all events. (see <a ext:cls="Ext.util.Observable" ext:member="resumeEvents" href="output/Ext.util.Observable.html#resumeEvents">resumeEvents</a>)</div> <div class="long"> Suspend the firing of all events. (see <a ext:cls="Ext.util.Observable" ext:member="resumeEvents" href="output/Ext.util.Observable.html#resumeEvents">resumeEvents</a>) <div class="mdetail-params"> <strong>Parameters:</strong> <ul><li>None.</li> </ul> <strong>Returns:</strong> <ul> <li><code>void</code></li> </ul> </div> </div> </div> </td> <td class="msource"><a ext:cls="Ext.util.Observable" ext:member="#suspendEvents" href="output/Ext.util.Observable.html#suspendEvents">Observable</a></td> </tr> <tr class="method-row inherited expandable"> <td class="micon"><a class="exi" href="#expand"> </a></td> <td class="sig"> <a id="Ext.data.Connection-un"></a> <b>un</b>( <code>String eventName</code>, <code>Function handler</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span> ) : void <div class="mdesc"> <div class="short">Removes a listener (shorthand for removeListener)</div> <div class="long"> Removes a listener (shorthand for removeListener) <div class="mdetail-params"> <strong>Parameters:</strong> <ul><li><code>eventName</code> : String<div class="sub-desc">The type of event to listen for</div></li><li><code>handler</code> : Function<div class="sub-desc">The handler to remove</div></li><li><code>scope</code> : Object<div class="sub-desc">(optional) The scope (this object) for the handler</div></li> </ul> <strong>Returns:</strong> <ul> <li><code>void</code></li> </ul> </div> </div> </div> </td> <td class="msource"><a ext:cls="Ext.util.Observable" ext:member="#un" href="output/Ext.util.Observable.html#un">Observable</a></td> </tr> </table> <a id="Ext.data.Connection-events"></a> <h2>Public Events</h2> <table cellspacing="0" class="member-table"> <tr> <th class="sig-header" colspan="2">Event</th> <th class="msource-header">Defined By</th> </tr> <tr class="event-row expandable"> <td class="micon"><a class="exi" href="#expand"> </a></td> <td class="sig"> <a id="Ext.data.Connection-beforerequest"></a> <b>beforerequest</b> : ( <code>Connection conn</code>, <code>Object options</code> ) <div class="mdesc"> <div class="short">Fires before a network request is made to retrieve a data object.</div> <div class="long"> Fires before a network request is made to retrieve a data object. <div class="mdetail-params"> <strong style="font-weight:normal;">Listeners will be called with the following arguments:</strong> <ul><li><code>conn</code> : Connection<div class="sub-desc">This Connection object.</div></li><li><code>options</code> : Object<div class="sub-desc">The options config object passed to the <a ext:cls="Ext.data.Connection" ext:member="request" href="output/Ext.data.Connection.html#request">request</a> method.</div></li> </ul> </div> </div> </div> </td> <td class="msource">Connection</td> </tr> <tr class="event-row alt expandable"> <td class="micon"><a class="exi" href="#expand"> </a></td> <td class="sig"> <a id="Ext.data.Connection-requestcomplete"></a> <b>requestcomplete</b> : ( <code>Connection conn</code>, <code>Object response</code>, <code>Object options</code> ) <div class="mdesc"> <div class="short">Fires if the request was successfully completed.</div> <div class="long"> Fires if the request was successfully completed. <div class="mdetail-params"> <strong style="font-weight:normal;">Listeners will be called with the following arguments:</strong> <ul><li><code>conn</code> : Connection<div class="sub-desc">This Connection object.</div></li><li><code>response</code> : Object<div class="sub-desc">The XHR object containing the response data.See <a href="http://www.w3.org/TR/XMLHttpRequest/">The XMLHttpRequest Object</a>for details.</div></li><li><code>options</code> : Object<div class="sub-desc">The options config object passed to the <a ext:cls="Ext.data.Connection" ext:member="request" href="output/Ext.data.Connection.html#request">request</a> method.</div></li> </ul> </div> </div> </div> </td> <td class="msource">Connection</td> </tr> <tr class="event-row expandable"> <td class="micon"><a class="exi" href="#expand"> </a></td> <td class="sig"> <a id="Ext.data.Connection-requestexception"></a> <b>requestexception</b> : ( <code>Connection conn</code>, <code>Object response</code>, <code>Object options</code> ) <div class="mdesc"> <div class="short">Fires if an error HTTP status was returned from the server.See HTTP Status Code Definitionsfor details of HTTP stat...</div> <div class="long"> Fires if an error HTTP status was returned from the server.See <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">HTTP Status Code Definitions</a>for details of HTTP status codes. <div class="mdetail-params"> <strong style="font-weight:normal;">Listeners will be called with the following arguments:</strong> <ul><li><code>conn</code> : Connection<div class="sub-desc">This Connection object.</div></li><li><code>response</code> : Object<div class="sub-desc">The XHR object containing the response data.See <a href="http://www.w3.org/TR/XMLHttpRequest/">The XMLHttpRequest Object</a>for details.</div></li><li><code>options</code> : Object<div class="sub-desc">The options config object passed to the <a ext:cls="Ext.data.Connection" ext:member="request" href="output/Ext.data.Connection.html#request">request</a> method.</div></li> </ul> </div> </div> </div> </td> <td class="msource">Connection</td> </tr> </table> </div>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -