PDA

View Full Version : Store, ScriptTagProxy and exception



sunco
18 Feb 2010, 3:00 PM
Based on this sample http://www.extjs.com/deploy/dev/examples/form/forum-search.html i use ScriptTagProxy and JsonReader for read stuff

Somebody on the forum says ScriptTagProxy is only to cross-domain

Is there a problem if i always use ScriptTagProxy even for local connections ?

Btw, my problem is that can't catch the exception, in this case a 404 error or simply a corrupted return of values

I use this to catch the exception with no luck



store.on('exception', errorStore);
function errorStore(proxy, options, response, error) {
// ???
}


Can somebody help providing a working sample please ?

goldledoigt
18 Feb 2010, 9:24 PM
You can use ScriptTagProxy for local connection if you want.
The thing to know is with ScriptTagProxy you can only handle a server response in JavaScript, because the server response will be inserted into <script /> tags.

To understand better how it works you should take a look to jsonp.js (http://www.extjs.com/playpen/ext-core-latest/examples/jsonp/jsonp.js) from this Ext Core example :
http://www.extjs.com/playpen/ext-core-latest/examples/jsonp/

sunco
19 Feb 2010, 9:01 AM
Thanks for your answer. Now i want to know the exact parameters of exceptions

I'm reading the docs but can't make it work, i mean, none of the parameters returns me the exact error text



storeAjax.on('exception', errorStoreAjax);
function errorStoreAjax(DataProxy, type, action, options, response, arg) {
if (type == "response") {
// 404 .. 500
alert(type + " - " + action + " - " + options + " - " + response + " - " + arg);
}
}


Using a "for each" on the objects does nothing



for (var x in response) {
alert(x + " - " + response[x]);
}

for (var x in options) {
alert(x + " - " + options[x]);
}

sunco
19 Feb 2010, 9:52 AM
Now i want to now how to retrieve the exact response from the server, in my case 404 because the file doesn't exist



storeAjax.on('exception', errorStoreAjax);
function errorStoreAjax(DataProxy, type, action, options, response, arg) {
if (type == "response") {
// 404 .. 500
alert(type + " - " + action + " - " + options + " - " + response + " - " + arg);
}
}


I try this but still no luck



for (var x in response) {
alert(x + " - " + response[x]);
}

for (var x in options) {
alert(x + " - " + options[x]);
}


Btw, can somebody please tell me why a user with 78+ posts need moderating messages? I think that is for new users, or when the post include 2+ links. Maybe a captcha ?

sunco
19 Feb 2010, 3:08 PM
Ok, thanks

Anything related to exception on ScriptTagProxy and JsonReader ? On ScriptTagProxy i can detect it but it don't return any specific. On JsonReader just can't make it work



var storeAjax = new Ext.data.Store({
proxy: new Ext.data.ScriptTagProxy({
url: 'includes/ajax.php',
timeout: 5000,
listeners: {
'exception': function(dataProxy, type, action, options, response, arg) {
// this is just a global error, i want detailed and action, options and response returns nothing
Ext.MessageBox.show({ title: 'Error', msg: 'Hubo un error al intentar leer los datos', buttons: Ext.MessageBox.OK, icon: Ext.MessageBox.ERROR });
}
}
}),
reader: new Ext.data.JsonReader({
root: 'calles',
totalProperty: 'registros',
id: 'id_calle',
fields: [
{name: 'nom_calle'},
{name: 'nom_colonia'},
{name: 'nom_ciudad'},
{name: 'nom_estado'}
]
})
});