sagarsgiri
22 Aug 2011, 2:00 PM
Hi,
How to set a proxy URL in ExtJS?
In Sproutcore, we have a Buildfile where we set -
proxy '/login' :to => 'localhost:4567'
In ExtJS, to post a JSON object, we use the following code:
Ext.Ajax.request({
url:'/login',
method: 'POST',
headers: {'Content-Type':'application/json'},
jsonData:{"userName": value,
"password": value,
},
success:function(response){
obj = Ext.util.JSON.decode(response.responseText);
Ext.Msg.alert('Status', '', obj);
},
failure:function(response){
if(action.failureType == 'server'){
obj = Ext.util.JSON.decode(response.responseText);
Ext.Msg.alert('', obj.errors.reason);
}else{
Ext.Msg.alert('','' +response.responseText);
}
}
});
Where should I set the URL -> http://localhost:4567 ??
The server is running @ localhost:4567. (I have to send JSON object to the url "http://localhost:4567/login" to get a response back.)
Thanks in advance.
How to set a proxy URL in ExtJS?
In Sproutcore, we have a Buildfile where we set -
proxy '/login' :to => 'localhost:4567'
In ExtJS, to post a JSON object, we use the following code:
Ext.Ajax.request({
url:'/login',
method: 'POST',
headers: {'Content-Type':'application/json'},
jsonData:{"userName": value,
"password": value,
},
success:function(response){
obj = Ext.util.JSON.decode(response.responseText);
Ext.Msg.alert('Status', '', obj);
},
failure:function(response){
if(action.failureType == 'server'){
obj = Ext.util.JSON.decode(response.responseText);
Ext.Msg.alert('', obj.errors.reason);
}else{
Ext.Msg.alert('','' +response.responseText);
}
}
});
Where should I set the URL -> http://localhost:4567 ??
The server is running @ localhost:4567. (I have to send JSON object to the url "http://localhost:4567/login" to get a response back.)
Thanks in advance.