PDA

View Full Version : How to get transactionId of Ajax request?



dbassett74
22 Jun 2009, 2:22 PM
Per the documentation for Ext.Ajax.request, it should return a transactionId. Although the following code successfully performs the request, it never returns a transactionId:



var id = Ext.Ajax.request({
url: 'Service.asmx/getAgencyData'
, method: 'POST'
, jsonData: { agencyId: pnl.getComponent('AgencyIdTextField').getValue()}
, headers: { 'Content-Type': 'application/json;charset=utf-8'}
, success: function(response, options) {
}
, failure: function(response, options) {
}
});
Ext.Msg.alert('transactionId', id); <--- this always has an empty object for id


What am I missing?

mrsunshine
22 Jun 2009, 3:11 PM
Ext.Msg.alert('transactionId', id);

Ext.Msg.alert second parameter expected a String but Ext.Ajax.request returns a object which contains the id as attribute.

dbassett74
22 Jun 2009, 3:18 PM
I don't understand. I know that the return object is a Number, but i tried id.toString(), but that doesn't work either. Can you please elaborate a little for me? Thanks.

hendricd
22 Jun 2009, 6:08 PM
@dbassett74-- The return value from an Ext.Ajax.request is an object (this connection object returned from Ext.lib.Ajax, in fact). And yes, the documentation (for Ext.data.Connection) has been incorrect for quite a while.



var req = Ext.Ajax.request({....});
Ext.Msg.alert('transactionId', req.tId); Pull up req in Firebug and snoop around. ;)

Dipish
19 Sep 2011, 6:24 AM
The doc for 3.x is still incorrect (http://dev.sencha.com/deploy/ext-3.3.1/docs/?class=Ext.Ajax) :(
It still says that request() returns a Number while it returs the request object.