-
23 Jan 2013 11:02 PM #1
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
-
24 Jan 2013 11:03 AM #2
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
-
24 Jan 2013 4:07 PM #3
-
24 Jan 2013 4:24 PM #4
Use firebug or chrome developer tools to see what is your application sending to the server.
Regards.UI: Sencha Architect 2.x / ExtJS 4 MVC
Server side: EJB 3.1 / CDI / JPA 2 / JAX-RS / JasperReports
Application Server: Glassfish 3.1.x
Databases: Oracle 10g & 11g / DB2 9 & 10 / Firebird 2.5
If you like my answer please vote!
-
27 Jan 2013 3:35 PM #5
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'); } }


Reply With Quote