PDA

View Full Version : Extjs to call a RESTful webservice



vivekc
1 Dec 2009, 7:00 AM
Hello,
I am trying to make a RESTful webservice call using Extjs. Below is the code i am using:



Ext.Ajax.request({ url: incomingURL ,
method: 'POST',
params: {param1:p1, param2:p2},
success: function(responseObject)
{ var obj = Ext.decode(responseObject.responseText);
alert(obj); },
failure: function(responseObject){
var obj = Ext.decode(responseObject.responseText); alert(obj); } });


but it does not work:((, the request is sent using OPTIONS method instead of POST.
I also tried to do the same thing using below code but result is the same:


var conn = new Ext.data.Connection(); conn.request({ url: incomingURL, method: 'POST', params: {param1:p1, param2:p2}, success: function(responseObject) { Ext.Msg.alert('Status', 'success'); }, failure: function(responseObject) { Ext.Msg.alert('Status', 'Failure'); } });


But when i tried to do the same thing using basic ajax call ( using the browser objects directly i.e. XMLHttpRequest() or ActiveXObject("Microsoft.XMLHTTP")) it works fine and i get the response as expected :-?.


Can anyone please help me, as i am not able to understand what i am doing wrong with extjs ajax call? :-/

tryanDLS
1 Dec 2009, 10:00 AM
http://extjs.com/learn/Ext_Forum_Help#How_to_post_code_properly

Requests usually get changed to OPTION by the Firefox when it thinks you're trying to go cross domain. Is that the case here?

vivekc
1 Dec 2009, 10:55 PM
We are trying to make a call between two applications deployed on different servers i.e. abc.mycomp.com makes an ajax call to def.mycomp.com.