Thursday, 15 March 2012

ajax - Extjs to call a RESTful webservice -


I'm trying to call a restful webservice using extjs below the code I am using: < / P>

  Ext.Ajax.request ({url: incomingURL, method: 'post', parameter: {param1: p1, param2: p2}, success: function (ResponseObject) {var obj = Ext. Decode (responseObject.responseText); alerts (obez);}, failure: function (response object) {var obj = Ext.decode (responseObject.responseText); alert (obz);}});  

But this does not work, the request is sent using the OPTIONS method instead of POST.

I also tried to use the code below but the result was the same:

  var conn = new Ext.data.Connection (); Conn.request ({url: incomingURL, method: 'post', parameter: {param1: p1, param2: p2}, success: function (feedback object) {Ext.Msg.alert ('condition', 'success'); }, Failure: function (response object) {Ext.Msg.alert ('condition', 'failure');}});  

But when I try to use the original AJAX call (using browser objects directly ie xmlHttpRequest ()) or ActiveXObject ("Microsoft.XMLHTTP") then it works fine and I get the feedback as expected.

Can someone help me, because I can not understand what I am doing wrong with AJAX calls?

You can not create a standard AJAX call between domains. The URL relative to Ext.Ajax.request (relative to the origin of the script) must be.

If you want to make cross-domain calls, use ScriptTagProxy or such.


No comments:

Post a Comment