PDA

View Full Version : how to set the asynchronism in Ext.data.connection



zf4000
28 May 2007, 9:44 PM
when i use Ext.data.connection to get the responseText returned from the server, the statment in Ext.data.connection.request() is exacuted later than that out of Ext.data.connection.request().
so , i think that may result from asynchronism of ajax.
but how to set the asynchronism in Ext.date.connection.
some one can help me?
here is the code


var con = new Ext.data.Connection();
con.request({
url: 'someurl',
method: 'GET',
loadMask: true,
callback: function(oElement,bSuccess,oRespons) {
alert('i am in Ext.data.Connection');
}
)
alert('i am out of Ext.data.Connection!');


the question is : 'i am out of ...' is erlier than 'i am in ...'

liggett78
28 May 2007, 11:16 PM
You think right. Ext.data.Connection.request() function executes asynchronously. This is what you want, don't you? Or what do you mean by "set asynchronism in Ext.date.connection"?

Animal
28 May 2007, 11:36 PM
It is asynchronous. There is no support in Ext for synchronous server requests.

zf4000
29 May 2007, 2:19 AM
i want the script " alert('i am out of Ext.data.Connection!'); " don't execute until the server return some response.
sometimes , i will do somthing according to the respons returned from server.
for example, init Class Ext.grid.ColumnModel from the fields information(json object) returned from server.

anybody can help me?

Animal
29 May 2007, 2:25 AM
Yes, that's what the callback is for: http://extjs.com/deploy/ext/docs/output/Ext.data.Connection.html#request

In the latest release there's also a "requestcomplete" event.

zf4000
29 May 2007, 5:25 PM
i have serched the sourcecode of Ext-all-debug and find the requestcomplete.
thanks

Animal
29 May 2007, 11:25 PM
Don't try that. Just use the callback as you are already doing.