-
21 Mar 2012 12:46 AM #1
Answered: OPTIONS (url) 405 (Method Not Allowed)
Answered: OPTIONS (url) 405 (Method Not Allowed)
Sorry if i ask a strange question as i am still new to Sencha Touch.I am facing a problem of the request method of Ajax Proxy in store always OPTIONS which cannot access my web service method, as the web service method is set to GET.Here is my code:
Code in sencha:Code:[WebInvoke(Method="GET", UriTemplate="GetCoupons",ResponseFormat=WebMessageFormat.Xml)] public List GetCoupons() { List rs = db.MMCO_sp_GetCoupons(null, null, 1).ToList(); foreach (MMCO_sp_GetCouponsResult temp in rs) { couponList.Add(new Coupon(temp.coupon_code); } return couponList; }
Error:Code:Ext.define("Next2Me.store.Coupons", { extend: "Ext.data.Store", config: { model: "Next2Me.model.Coupon", autoLoad: true, root: { expanded: true }, proxy: { type: 'ajax', url: 'http://localhost:11827/CouponJSON.svc/web/GetCoupons', reader: { type: 'xml' } } } })
Untitled.jpg
Return of Web Service Method:
Untitled.jpg
-
Best Answer Posted by mitchellsimoens
You are trying to use ajax cross-origin which doesn't work. You can try using CORS (not currently supported within ST2) and this is the reason you are seeing the OPTIONS request. The browser first sends this request to see if the server supports CORS in order to allow the ajax fire cross-origin.
-
21 Mar 2012 5:27 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,117
- Vote Rating
- 454
- Answers
- 3159
You are trying to use ajax cross-origin which doesn't work. You can try using CORS (not currently supported within ST2) and this is the reason you are seeing the OPTIONS request. The browser first sends this request to see if the server supports CORS in order to allow the ajax fire cross-origin.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
21 Mar 2012 7:11 AM #3
Thanks. So what should be the solution since cors not supported st2. Any suggestion ?
-
21 Mar 2012 7:13 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,117
- Vote Rating
- 454
- Answers
- 3159
JsonP is the only other route but requires you to return JSON within a callback function.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
21 Mar 2012 6:13 PM #5
Thanks a lot, buddy.
I solved my problem with JsonP.
-
6 Nov 2012 12:53 AM #6
So how do I do authorization when ST2 doesn't support CORS and I can't do POST requests with JSONP to send login/pass?
-
6 Nov 2012 12:57 AM #7
You can run a server-side script which acts as a proxy for all calls.


Reply With Quote