PDA

View Full Version : Ajax Call : Connection Failed



tdikarim
10 Mar 2011, 3:19 AM
Hi,

I run on my local WebServer. And I call a php that is on another server.
That work's fine when I call this Php for populate the grid.

But When I click on a button of the toolbar for call this same php for to do an action (send a mail)
I have a connection failed.

I know I must use ScriptTagProxy. But hereI wan't to populate a grid but just execute an action on the server.



Ext.Ajax.request({
url: 'http://xxx.xxx.xxx.xx/TK/DEV/serveur/php/sendemail.php',
params: {
,action: 'sendEmail'
,data : Ext.util.JSON.encode(JSonData)
,dateLaunch : this.tb_dateField.getValue().format('Y-m-d') || null
,userNAme: this.app.memberInfo.name
},
callback: function(options, success, response) {
result = Ext.decode(response.responseText);

if (result.success == true) {
console.info('Success');
}
else{
console.info('Failure');
}
},
scope: this
});


Thanks for your help
Karim

steffenk
10 Mar 2011, 3:40 AM
Do not use absolute urls for the url-property, use relative one, eg

url: '/TK/DEV/serveur/php/sendemail.php'

tdikarim
10 Mar 2011, 4:53 AM
But If I do that, I will execute the sendmail.php that must be found on my local server.
But here I must to execute on php that found on another server AIX delocalized.

For more explaination
the application run on a local server but must call some php on an external server

windows ==> AIX
oracle DB2

If it is not possible, I will try to execute the action from a datastore
maybe something like this (but isn't cleaner):



var AjaxCall = new Ext.data.JsonStore({
proxy: new Ext.data.ScriptTagProxy({
url:'http://xxx.xxx.xxx.xx/TK/DEV/serveur/php/sendemail.php'
}),
baseParams:{
action: 'sendEmail'
,data : Ext.util.JSON.encode(JSonData)
,dateLaunch : this.tb_dateField.getValue().format('Y-m-d') || null
,userNAme: this.app.memberInfo.name
},
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total'
},
[{name:'id',type:'numeric'}, {name: 'result_name',type: 'string'}]
)
});
AjaxCall.load({params : {start : 0}});


Thanks
Karim

steffenk
10 Mar 2011, 4:58 AM
Cross-site-requests are not allowed for security reasons. The only way would be a ScriptTagProxy (http://dev.sencha.com/deploy/dev/docs/?class=Ext.data.ScriptTagProxy).

tdikarim
10 Mar 2011, 5:08 AM
Yes, I know that.
But I have not found any sample for execute a php that is in another domain without use a datastore...