1

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?

Anand Soni
  • 5,070
  • 11
  • 50
  • 101
  • 1
    Are you doing the request also from http://localhost:3000/? This might be a possible duplicate of http://stackoverflow.com/questions/1256593/jquery-why-am-i-getting-an-options-request-insted-of-a-get-request – Nicodemuz Mar 26 '11 at 05:16

3 Answers3

1

Add parameter:

useDefaultXhrHeader : false

If not, GET and POST method request will contain X-Requested-With header. I think this header is the reason why OPTIONS method request is sent.

John Wong
  • 342
  • 2
  • 10
0

This is a question about CORS.This is my web.conf for asp.net:

<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
<httpProtocol>
  <customHeaders>
    <add name="Access-Control-Allow-Origin" value="*" />
    <add name="Access-Control-Allow-Headers" value="X-Requested-With,Content-Type" />
  </customHeaders>
</httpProtocol>

It worked in the IIS Server,but not OK in Asp.net Developer Server.

avatas
  • 155
  • 2
  • 7
-3

use JSONP insted of Ajax.request