Ext. Ajax. Request Synchronization

Source: Internet
Author: User

Ext. ajax. this parameter is not synchronized in the request parameter. However, many requests need to be synchronized to provide data in componnet without the add method. For example, the dynamic check option in checkboxgroup should be modified. ajax. the real Request Method Ext. lib. ajax. request
The code is from the ext official forum:
Ext. Lib. Ajax. Request = function (method, Uri, CB, Data, options ){
If (options ){
VaR HS = options. headers;
If (HS ){
For (VAR h in HS ){
If (HS. hasownproperty (H )){
This. initheader (H, HS [H], false );
}
}
}
If (options. xmldata ){
If (! HS |! HS ['content-type']) {
This. initheader ('content-type', 'text/xml', false );
}
Method = (method? Method: (options. method? Options. Method: 'post '));
Data = options. xmldata;
} Else if (options. jsondata ){
If (! HS |! HS ['content-type']) {
This. initheader ('content-type', 'application/json', false );
}
Method = (method? Method: (options. method? Options. Method: 'post '));
Data = typeof options. jsondata = 'object '? Ext. encode (options. jsondata): Options. jsondata;
}
}

Return this ["sync" in options? "Syncrequest": "asyncrequest"] (method, Uri, CB, data); // specifies the method to call. If sync is passed, syncrequest is called, otherwise, the original method asyncrequest} is called };

The syncrequest method is as follows:
Ext. Lib. Ajax. syncrequest = function (method, Uri, callback, postdata)
{
VaR o = This. getconnectionobject ();

If (! O ){
Return NULL;
}
Else {
O. Conn. Open (method, Uri, false );

If (this. usedefaultxhrheader ){
If (! This. defaultheaders ['x-requested-with']) {
This. initheader ('x-requested-with', this. defaultxhrheader, true );
}
}

If (postdata & this. usedefaultheader &&(! This. hasheaders |! This. headers ['content-type']) {
This. initheader ('content-type', this. defaultpostheader );
}

If (this. hasdefaultheaders | this. hasheaders ){
This. setheader (O );
}

O. Conn. Send (postdata | null );
This. handletransactionresponse (O, callback );
Return O;
}
};

Call:
Ext. Ajax. Request ({
URL :'',
Scope: This,
Sync: True,
Success: function (){}
});

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.