JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://dl.dropbox.com/u/1015920/Ext/Ext.ux.ajax.SimXhr.js"></script>
<script src="http://dl.dropbox.com/u/1015920/Ext/Ext.ux.ajax.Simlet.js"></script>
<script src="http://dl.dropbox.com/u/1015920/Ext/Ext.ux.ajax.JsonSimlet.js"></script>
<script src="http://dl.dropbox.com/u/1015920/Ext/Ext.ux.ajax.SimManager.js"></script>
JavaScript
/*
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.Ajax
*/
Ext.define('My.model.Contact', {
extend: 'Ext.data.Model',
fields: [
'name',
'phone'
],
proxy: {
type: 'ajax',
url: '/contacts',
reader: {
type: 'json',
root: 'contacts'
}
}
});
Ext.application({
name:'My',
autoCreateViewport:true,
launch: function() {
var sim = Ext.ux.ajax.SimManager.init();
sim.register({
'/contacts': {
status: 403
}
});
Ext.Ajax.on('beforerequest', this.onAjaxBeforeRequest, this);
Ext.Ajax.on('requestcomplete', this.onAjaxRequestComplete, this);
Ext.Ajax.on('requestexception', this.onAjaxRequestException, this);
My.model.Contact.load(1, {
success: function() {
console.log('success', arguments);
},
failure: function() {
console.log('fail', arguments);
}
});
},
showThrobber:function(){
console.log('showing throbber');
},
hideThrobber:function(){
console.log('hiding throbber');
},
onAjaxBeforeRequest: function(conn, options, eOpts) {
console.log('before request');
this.showThrobber();
},
onAjaxRequestComplete: function(conn, response, options, eOpts) {
console.log('request complete');
this.hideThrobber();
},
onAjaxRequestException: function(conn, response, options, eOpts) {
this.hideThrobber();
console.log('request exception');
switch (response.status) {
case 401:
this.onAuthenticationRequired(conn, response, options, eOpts);
break;
case 403:
this.onRequestUnauthorized(conn, response, options, eOpts);
break;
default:
break;
}
},
onRequestUnauthorized:...