1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    19
    Vote Rating
    1
    honggang.z.zhu is on a distinguished road

      0  

    Default can not call the web service when form is submited

    can not call the web service when form is submited


    I made a form panel, when I click save button, I want to call the web service to add data.
    I published the web site and web service on my computer, On my own computer the form is submitted successfully, but on another computer, the form is submitted failure, alert message 'Ajax communication failed'.
    case Ext.form.action.Action.CONNECT_FAILURE:
    Ext.Msg.alert('Failure', 'Ajax communication failed');

    Untitled.png


    If I do not use form submit, I use the store.load to call a web service, it can works well when I access the web site on another computer. I don't know why, please help me. thanks.

    blow is the code:
    Code:
    var me = this;
    var _webServiceUrl = 'http://10.40.33.195/MRCReceivingWS/Bas/Area.asmx/Add';
    
    
    var _userId = Ext.getCmp('lblGID').text;
    
    
    var form = button.up('form').getForm();
    form.submit({
        url: _webServiceUrl,
        method: 'POST', 
        params: {
            userId: _userId
        },
        success: function(form, action) {        
            switch(app.AppConfig.g_pagEditFlag){
                case 1:                
                Ext.Msg.alert('Success', action.result.msg, function(){                
                    button.up('form').getForm().reset();
                    app.controller.CommonLogic.elmentGetFocus('txtAreaName', false);
                    me.queryData();
                });
                break;
                case 2:
                Ext.Msg.alert('Success', action.result.msg, function(){
                    me.getPageBasAreaEdit().close();                
                    me.queryData();
                });                
                break;
            }
    
    
    
    
        },
        failure: function(form, action) {
            switch (action.failureType) {
                case Ext.form.action.Action.CLIENT_INVALID:
                Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values');
                break;
                case Ext.form.action.Action.CONNECT_FAILURE:
                Ext.Msg.alert('Failure', 'Ajax communication failed');
                break;
                case Ext.form.action.Action.SERVER_INVALID:
                Ext.Msg.alert('Failure', action.result.msg);
            }
        }
    });
    Last edited by aconran; 24 Jan 2013 at 10:22 AM. Reason: add code tags

  2. #2
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,363
    Vote Rating
    128
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    You need to serve the page from the same server. Are they both on 10.40.133.195?
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  3. #3
    Sencha User
    Join Date
    Oct 2012
    Posts
    19
    Vote Rating
    1
    honggang.z.zhu is on a distinguished road

      0  

    Default


    yes, they are on the same server.

  4. #4
    Sencha Premium Member
    Join Date
    May 2010
    Location
    Guatemala, Central America
    Posts
    1,306
    Vote Rating
    110
    ssamayoa is just really nice ssamayoa is just really nice ssamayoa is just really nice ssamayoa is just really nice ssamayoa is just really nice

      0  

    Default


    Use firebug or chrome developer tools to see what is your application sending to the server.

    Regards.
    UI: Sencha Architect 3.x / ExtJS 4 & 5
    Server side: JEE / EJB 3.x / CDI / JPA 2.x/ JAX-RS / JasperReports
    Application Server: Glassfish / WildFly
    Databases: Oracle / DB2 / MySQL / Firebird

    If you like my answer please vote!

  5. #5
    Sencha Premium Member
    Join Date
    Feb 2012
    Posts
    25
    Vote Rating
    0
    c5m7b4 is on a distinguished road

      0  

    Default


    I had a similar issue when developing my first IOS app. Obviously I would be running the app from a phone so I would need to access a url on a different network so I just used a JSONP call. Now I'm religous using JSONP, lol. Normally all my ExtJS stuff is served from the same server as php/web service is located. Here is some sample code in case it helps any:

    Code:
        onSaveTap: function(button, e, options) {
            var me = this,
                form = this.getCustomerDetail(),
                values = form.getValues(),
                record = form.getRecord();
    
    
            record.beginEdit();
            record.set(values);
    
    
            if ( record.isValid()){
                record.endEdit();
    
    
                var id = record.data.id;
    
    
                var notes = record.data.notes;
    
    
                var visitType = record.data.visitType;
    
    
                Ext.data.JsonP.request({
                    url:'http://www.myUrl:8080/Prospects/data/create_ProspectCall.php?notes=' + notes + '&visitType=' + visitType + '&id=' + id + '&userid=1',
                    callback:'callback',
                    success:function(response, result){
                        var errorCode = response.error;
                        switch(errorCode){
                            case '0':
                                Ext.Msg.alert('Success', 'Your Call has been submitted');
                                break;
                            default:
                                Ext.Msg.alert('Alert', response.msg);
                                break;
                        }
                    }
                });
            }
            else{
                record.cancelEdit();
                Ext.Msg.alert('Error', 'There were errors with the record');
            }
    
    
        }

Thread Participants: 3