PDA

View Full Version : How to show error when backend of apllication is unavailable



hudi1
6 Jun 2013, 4:35 AM
Hi

I have simply submit action:


form.submit({
scope : this,
success : function(form, action) {
this.reloadContacts(dialog, action.result.id, button);
var contact = form.getRecord();
contact.set(values);
contact.data.version = action.result.version;
form.loadRecord(contact);

},
failure : function(form, action) {
console.log(action.result);
button.enable();
}

});

this call method which I defined in api of form:


api : {
submit : 'simpleService.createPerson'
},


Problem is when my backend is unavailable. Success or failure are not called. How I can report this error to client ? (Some allert window)

Just console show error:

Uncaught Error: [Ext.Loader] Failed loading synchronously via XHR: '
http://localhost:8080/ext/src/form/action/DirectSubmit.js
'; It's likely that the file is either being loaded from a different domain or from the local file system whereby cross origin requests are not allowed due to security reasons. Use asynchronous loading with Ext.require instead


but I want to do something (enable button) and show message to client

slemmon
10 Jun 2013, 10:38 AM
You might watch for requestexception events on Ext.Ajax. Something like:



Ext.Ajax.on('requestexception', function (conn, response, options) {
if (response.status === 403) {
// handle 403 error
}
});