Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Touch Premium Member
    Join Date
    May 2010
    Posts
    8
    Vote Rating
    0
    yozik04 is on a distinguished road

      0  

    Default Ext Direct no callback if server returned junk

    Ext Direct no callback if server returned junk


    Version 4.1-rc1
    File: Ext.direct.RemotingProvider
    Code:
        onData: function(options, success, response){
            var me = this,
                i = 0,
                len,
                events,
                event,
                transaction,
                transactions;
    
            if (success) {
                events = me.createEvents(response);
                for (len = events.length; i < len; ++i) {
                    event = events[i];
                    transaction = me.getTransaction(event);
                    me.fireEvent('data', me, event);
                    if (transaction) {
                        me.runCallback(transaction, event, true);
                        Ext.direct.Manager.removeTransaction(transaction);
                    }
                }
            } else {


    transaction variable is null when server returned junk.
    That is why no callback is called.

    The same result if server returned empty text. Javascript error appears, no callback received.
    Last edited by yozik04; 29 Mar 2012 at 7:12 AM. Reason: empty text

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,135
    Vote Rating
    855
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Thanks for the report.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,925
    Vote Rating
    634
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    For a direct request to be processed, it needs to return a valid set of JSON data, otherwise we can never identify which transactions we need to process, this is especially important when we consider request batching.

    The provider will fire a "data" event each time it receives data. In the cases where it can't parse the event, it will send an exception object as the parameter to the data event.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  4. #4
    Sencha Premium Member
    Join Date
    Mar 2012
    Posts
    72
    Vote Rating
    6
    Lukappa is on a distinguished road

      0  

    Default


    I found a way to do it... adding a listener (exception) on direct and "forcing" to execute the code in the callback:

    the main app code:
    Code:
    Ext.direct.Manager.addProvider(Ext.app.REMOTING_API);
    Ext.direct.Manager.on('exception', function(opts) {
            opts.xhr.request.options.transaction.callback(null, null);
        }, this);
    ....
    the direct request code (it could be in some controller):
    Code:
    Ext.app.myClass.myMethod(params, function(provider, response){
        if(response == null) {
              alert("Server error");
        } else {
              console.log(response.result)
             //your code
        }
    });
    ....
    the server side code (example of error)

    Code:
    <?php
    public function myMethod($params) { 
        return 5/0; //<--- this will produce a "division by zero" php Warning
    }
    //...
    So in this way I found a simple 'trick' to handle some problem about server system, php notice & warning and so on...

    I'm not a extjs guru =) and I'd like to know what sencha devs think about it, thank you.