PDA

View Full Version : POST request in Sencha Touch using Ajax



sonianand11
25 Mar 2011, 8:15 PM
HI, I am trying to make a POST request using Ajax in sencha touch. my problem is when I am sending request my server accepts it as OPTIONS request. my code is :

var post_json = { usrname: username, password: password } ;

Ext.Ajax.request({
url: 'http://localhost:3000/',
method: "POST",
params: {
user_session: post_json
},
success: function(){
alert("sucessful");

},
failure: function(){
alert("fail");
}

});

How can i solve this problem?

jay@moduscreate.com
29 Mar 2011, 4:37 AM
maybe: user_session: Ext.util.JSON.encode(post_json)

danmux
22 May 2011, 2:47 PM
I think you are seeing the pre-flight OPTIONS request when Cross-Origin Resource Sharing or cross site scripting...

http://www.w3.org/TR/cors/

I suspect your web page serving the JS is not on port 3000 - but your Ajax call is...

on mac - try...

open -a '/Applications/Safari.app' --args --disable-web-security

I cant get this to work, though others have..
This works for me on Chrome...

open -a '/Applications/Google Chrome.app' --args --disable-web-security

zeroprg
29 May 2012, 9:23 AM
I tried to find EXT.Ajax object in Architect but failed. How to wire Ajax.request to AjaxProxy or other visual object. I want to make Ajax.request in Sencha Architect 2.