Results 1 to 5 of 5

Thread: Store, ScriptTagProxy and exception

  1. #1
    Ext User
    Join Date
    Mar 2009
    Location
    Sinaloa, Mxico
    Posts
    102

    Default Store, ScriptTagProxy and exception

    Based on this sample http://www.extjs.com/deploy/dev/exam...um-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

    Code:
    store.on('exception', errorStore);
    function errorStore(proxy, options, response, error) {
        // ???
    }
    Can somebody help providing a working sample please ?

  2. #2
    Sencha Premium Member goldledoigt's Avatar
    Join Date
    Jul 2007
    Location
    Paris, France
    Posts
    56

    Default

    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 from this Ext Core example :
    http://www.extjs.com/playpen/ext-cor...xamples/jsonp/
    Goldledoigt

  3. #3
    Ext User
    Join Date
    Mar 2009
    Location
    Sinaloa, Mxico
    Posts
    102

    Default

    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

    Code:
    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

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

  4. #4
    Ext User
    Join Date
    Mar 2009
    Location
    Sinaloa, Mxico
    Posts
    102

    Default

    Now i want to now how to retrieve the exact response from the server, in my case 404 because the file doesn't exist

    Code:
    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

    Code:
    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 ?

  5. #5
    Ext User
    Join Date
    Mar 2009
    Location
    Sinaloa, Mxico
    Posts
    102

    Default

    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

    Code:
    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'}
            ]
        })
    });

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •