Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Ext.Ajax Communication Failure

  1. #1
    Sencha Premium Member
    Join Date
    Aug 2007
    Posts
    38

    Default Ext.Ajax Communication Failure

    I'm using the Ext.Ajax class to get combo box data for a form. I recently made some changes and I now fire events in the success and failure methods of the Ajax call. I then of course have event handlers to either populate the combo box, or show an error depending on which event is fired.

    Since I added the events the Ajax call fails after some time i.e. for the first ten or 20 calls everything works fine. The Ajax call then starts failing with a message "Communication failure". This happens in both IE 7 and Firefox.

    I have used Firebug to trace the error up to a method call in ext-base.js, but since I don't have the debug version of this file I can't easily debug further.

    I know this is a long shot but does anyone have any idea what might be happening.

    Thanks
    Andrew

  2. #2
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    SOunds a bit too complicated to understand without seeing some code.

  3. #3
    Sencha Premium Member
    Join Date
    Aug 2007
    Posts
    38

    Default ext-base.js

    Yeah Animal that's what I thought.

    Do you know where can I get a non minified version of ext-base.js so I can debug a bit further?

    This is my code:
    PHP Code:
    /**
     * Class represents a division and zone selection.
     * 
     * @param {Object} name - The name for this divzone object. Usually the name of
     * a report with which it is associated. 
     */
    function DivisionAndZonesname ) {
        
    this.name name;
        
    this.selectedDivision Ext.state.Manager.getthis.name 'division');
        if( !
    this.selectedDivision ) {
            
    this.selectedDivision '01';        
        }

        
    //Events that will be fired by this class
        
    this.addEvents({
            
    'divisionsFetchSuccess' true,
            
    'zonesFetchSuccess' true,
            
    'divZoneFetchFail' true
        
    });

        
    this.divisionDS = new Ext.data.SimpleStore({
            
    id0,
            
    data: {},
            
    fields: ['value''division'],
            
    editable:false
        
    });
            
        
    this.divisionsCombo = new Ext.form.ComboBox( {
            
    name'division',        
            
    fieldLabel'Division',
            
    valueField'value',
            
    displayField:'division',    
            
    storethis.divisionDS,        
            
    selectOnFocustrue,
            
    mode'local',
            
    typeAheadtrue,
            
    editablefalse,
            
    triggerAction'all',
            
    valuethis.selectedDivision,
            
    width180,
            
    listWidth180
        
    });

        
    this.zonesDS = new Ext.data.SimpleStore({
            
    id0,
            
    data: {},
            
    fields: ['value''zone'],
            
    editable:false
        
    });
        
        
    this.zonesCombo = new Ext.form.ComboBox( {
            
    name'zone',            
            
    fieldLabel'Zone',
            
    valueField'value',                    
            
    displayField:'zone',    
            
    storethis.zonesDS,        
            
    selectOnFocustrue,
            
    mode'local',
            
    typeAheadtrue,
            
    editablefalse,
            
    triggerAction'all',
            
    value'BI',
            
    width180,
            
    listWidth180
        
    });

        
    /**
         * Set the zones for the given combobox
         * 
         * @param {Object} params - The parameters to pass with the Ajax request. Parameters must include
         *         division for which we want the zones. 
         */
        
    this.setZones = function( params ){
            var 
    zones Ext.state.Manager.get'zones' this.selectedDivision );
            
    //log( "-->Zones (zones" + this.selectedDivision + "): " + zones );
            
    if (zones) {
                
    this.zonesDS.loadDatazones );
                
    this.fireEvent('zonesFetchSuccess');
            }
            else {
                
    this.getDivisionsZones("zone"params);
            }
        }
        
        
    /**
         * Function called when zones have been fetched
         */
        
    this.gotZone = function() {
            
    selected Ext.state.Manager.getthis.name 'zone' );
            if( 
    selected ) {
                
    this.zonesCombo.setValue(selected);
            }
            else {
                
    this.zonesCombo.setValue("All Zones");
            }        
            
    this.zonesCombo.enable();
        }
        
    //Add listener for zone fetch success
        
    this.on'zonesFetchSuccess'this.gotZone );
        
        
    /**
         * Set the divisions for the given combobox
         * 
         */
        
    this.setDivisions = function( params ) {
            var 
    divisions Ext.state.Manager.get'divisions' );
            
    //log( "-->Divisions (divisions): " + divisions );
            
    if (divisions) {
                
    this.divisionDS.loadDatadivisions );
                
    this.fireEvent('divisionsFetchSuccess');
            }
            else {
                
    this.getDivisionsZones("division"params);
            }
        }

        
    /**
         * Function called when divisions have been fetched
         */
        
    this.gotDivision = function() {
            
    selected Ext.state.Manager.getthis.name 'division');
            if (
    selected) {
                
    this.divisionsCombo.setValueselected );
            }        
            
    this.divisionsCombo.enable();
        }
        
    //Add listener for division fetch success
        
    this.on'divisionsFetchSuccess'this.gotDivision );
        
        
    /**
         * 
         * @param {Object} which - division or zone
         * @param {Object} params
         */
        
    this.getDivisionsZones = function( whichparams ) {
            if (
    which == 'division') {
                
    this.divisionsCombo.disable();
            }
            else if( 
    which == 'zone' ) {
                
    this.zonesCombo.disable();
            }
            
    Ext.Ajax.request({
                   
    url'/fit/alert/inputs.do?reportName=general',
                
    waitMsg:'Fetching divisions and zones...',
                
    paramsparams,
                
    timeout180000,
                
    success: function( responseoptions ){        
                    try {
                        
    /*
                         json data returned is in the following format
                         [
                            {
                            "name":"division",
                            "selected":"05",
                            "values":[["01","01 ALABAMA"],...["06","06 GEORGIA"]]
                            },
                            {
                            "name":"zone",
                            "selected":"",
                            "values":[["","All"],,...,["All Zones","All Zones"]]
                            },
                            {"selected":"a","values":[],"name":"exceptionReportInput"},
                            {"selected":"03/27/08","values":[],"name":"from"},
                            {"selected":"03/27/08","values":[],"name":"to"}
                        ]*/
                        
    var resp = eval( '(' response.responseText ')' );
                        if( 
    resp.success ) {
                            if( 
    resp.success == 'false' ) {
                                
    Ext.Msg.show( { title'Error'msgresponse.error } );                        
                            }
                        }
                        else {
                            var 
    inputs = eval( '(' response.responseText ')' );
                            if (
    which == 'division') {
                                for (
    0inputs.lengthi++) {
                                    if (
    inputs[i].name == "division" ) {
                                        
    options.that.divisionDS.loadData(inputs[i].values);
                                        
    Ext.state.Manager.set'divisions'inputs[i].values );                                    
                                        
    //log( "-->Setting divisions (divisions): " + inputs[i].values );
                                        
    break;
                                    }
                                }
                                
    options.that.fireEvent('divisionsFetchSuccess');
                            }
                            else if (
    which == 'zone') {
                                for (
    0inputs.lengthi++) {
                                    if (
    inputs[i].name == "zone" ) {
                                        
    options.that.zonesDS.loadData(inputs[i].values);
                                        
    Ext.state.Manager.set'zones' options.that.selectedDivisioninputs[i].values );                                    
                                        
    //log( "-->Setting zones (zones" + options.that.selectedDivision + "): " + inputs[i].values );
                                        
    break;
                                    }
                                }
                                
    options.that.fireEvent('zonesFetchSuccess');
                            }
                        }
                    } 
                    catch (
    e) {
                        
    Ext.Msg.show( { title'Error'msge.message } );                        
                    }
                },
                
    failure: function( responseoptions ){
                    try {
                        
    alert"Failed to get division and zones: " response.statusText );
                        
    options.that.divisionsCombo.enable();
                        
    options.that.zonesCombo.enable();
                        
    options.that.fireEvent'divZoneFetchFail' );                    
                    } 
                    catch (
    e) {
                        
    Ext.Msg.show( { title'Error'msge.message } );                        
                    }
                },
                
    thatthis
            
    });            
        }    
        
        
    //When a new division is selected the zone combo must be updated with the 
        //zones for the newly selected division
        
    this.divisionsCombo.on'select', function divisionChanged() {
            
    this.selectedDivision this.divisionsCombo.getValue();
            
    Ext.state.Manager.setthis.name 'division'this.selectedDivision );

            
    //Set new zones
            
    Ext.state.Manager.setthis.name 'zone'"All Zones" );        
            
    this.setZones( { divisionthis.selectedDivision } );
        }, 
    this );

        
    //When a new zone is selected save it
        
    this.zonesCombo.on'select', function zonesChanged() {
            
    Ext.state.Manager.setthis.name 'zone'this.zonesCombo.getValue() );
        }, 
    this );
        
        
    this.init = function() {
            
    this.setDivisions( { "Division"this.division } );
        };
    }

    //Make DivisionAndZones Observable so it can be observered and send events to the observers. 
    //Notably an event will be fired after the divisions and zones are received by
    //the Ajax call 
    Ext.extendDivisionAndZonesExt.util.Observable ); 

  4. #4
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    I'm not sure, but you could try experimenting with the JSB builder which builds the ext code and adapters.

    I agree its difficult to debug adapter code because there's no ext-base-debug.js

  5. #5
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996

    Default

    Quote Originally Posted by anortje View Post
    Yeah Animal that's what I thought.

    Do you know where can I get a non minified version of ext-base.js so I can debug a bit further?
    http://extjs.com/forum/showthread.php?t=23734

  6. #6
    Sencha Premium Member
    Join Date
    Aug 2007
    Posts
    38

    Default Thanks

    Great! Thanks.

  7. #7
    Sencha Premium Member
    Join Date
    Aug 2007
    Posts
    38

    Default Status Code 0

    I was able to do some debugging and found that the XMLHttpRequest status code was sometimes 0 - the request to the server is not even "making it out".

    I found this http://ajaxian.com/archives/xmlhttpr...-status-code-0 which may be the issue I'm having

    i.e. I have a Ext form with a button which has a handler which makes an Ajax request.

    Any comments.

  8. #8
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996

    Default

    No input for solution, but FYI see my grid faq where there's a section on listeners with proxy and ajax listeners available. If you stuck those in maybe those would have helped you detect the problem easier. It would have just been an indicator perhaps, no doubt debugging would be the 'better' way to go to find the real problem.

  9. #9
    Ext User halkon_polako's Avatar
    Join Date
    Nov 2007
    Location
    Barcelona
    Posts
    193

    Default

    @anortje
    When I have a communication failure with status code 0, is because a timeout happened. The default time out is 30 seconds (I think).
    This happens to me when putting a breakpoint on my server code (it is a java backend) on development process... you can check your back end response time ...

  10. #10
    Sencha User hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,966

    Default

    @@anortje -- To get you thru your debugging issues (possibly others) try ext-basex (sig below) it contains raw source (for debugging) but also a full event harness that you can use to trace activity.

    One thing you might want to look at in your success handler code:

    Code:
    var resp = Ext.decode( response.responseText); 
      if( resp.success ) { if( typeof resp.success != 'undefined') {
      if( resp.success == 'false' ) { 
             Ext.Msg.show( { title: 'Error', msg: response.error } );                         
      } 
                        } 
                        else { 
                            var inputs = eval( '(' + response.responseText + ')' ); 
                            if (which == 'division') { 
                                for (i = 0; i < inputs.length; i++) { 
                                    if (inputs[i].name == "division" ) { 
                               
    .. may be causing unwanted behaviour (if not now, later ... )
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


Page 1 of 2 12 LastLast

Posting Permissions

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