1. #1
    Ext JS Premium Member
    Join Date
    Dec 2008
    Posts
    61
    Vote Rating
    0
    jeroenooms is on a distinguished road

      0  

    Default how to disable Ajax.request method="OPTIONS"

    how to disable Ajax.request method="OPTIONS"


    I use an Ajax request to download xml data from Google's Spreadsheet API. The Google server only allows 'GET' requests. However, for some reason when I create an Ext.Ajax.request to an external url (i.e. one that starts with http://), Ext uses method "OPTIONS" instead of "GET", resulting in a 405 method denied from Google. Even when explicitly method: "GET" is set in the Ajax.request config, it still uses method OPTIONS. How do I prevent this?
    Code:
    		Ext.Ajax.request({
    			url: 'http://www.google.com',
    			method: "GET"
    		});

  2. #2
    Sencha User darthwes's Avatar
    Join Date
    Mar 2010
    Posts
    633
    Vote Rating
    -11
    darthwes can only hope to improve

      0  

    Default


    We need a code example. Can you make the smallest possible code example that demonstrates the problem and post it on the forums?

  3. #3
    Ext JS Premium Member
    Join Date
    Dec 2008
    Posts
    61
    Vote Rating
    0
    jeroenooms is on a distinguished road

      0  

    Default


    Ok I added the code for you.

  4. #4
    Sencha User darthwes's Avatar
    Join Date
    Mar 2010
    Posts
    633
    Vote Rating
    -11
    darthwes can only hope to improve

      0  

    Default


    So 405 errors can arise because the Web server is not configured to take data from the client at all. They can also arise if the client does not have sufficient authority to the particular URL resource identified on the request.
    http://www.checkupdown.com/status/E405.html

  5. #5
    Sencha - Community Support Team hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,963
    Vote Rating
    10
    hendricd will become famous soon enough hendricd will become famous soon enough

      0  

    Default


    Quote Originally Posted by jeroenooms View Post
    I use an Ajax request to download xml data from Google's Spreadsheet API. The Google server only allows 'GET' requests. However, for some reason when I create an Ext.Ajax.request to an external url (i.e. one that starts with http://), Ext uses method "OPTIONS" instead of "GET", resulting in a 405 method denied from Google. Even when explicitly method: "GET" is set in the Ajax.request config, it still uses method OPTIONS. How do I prevent this?
    Code:
            Ext.Ajax.request({
                url: 'http://www.google.com',
                method: "GET"
            });
    @jeroenooms --
    Firefox generates on HTTP option verb when it thinks you are attempting a cross-domain request.
    Altho Firefox supports such a request, Googles servers do not respond with the necessary 'Allow-Origin' headers for you to succeed. Google up on 'same-origin' requests.
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  6. #6
    Ext JS Premium Member
    Join Date
    Dec 2008
    Posts
    61
    Vote Rating
    0
    jeroenooms is on a distinguished road

      0  

    Default


    @hendricd

    so, any idea how to fix this? Or is it just impossible to do cross-domain requests to google services with firefox? That can't be the case because there are many other 3rd party google service apps, that work in FF...

  7. #7
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,546
    Vote Rating
    62
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Try

    Code:
    Ext.lib.Ajax.useDefaultHeader = false;
    Even if a server does accept x-domain, I have found that the X-Requested-With header breaks it.

  8. #8
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,546
    Vote Rating
    62
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Also , use disableCaching: false

    I at least get a response from the server:


  9. #9
    Ext JS Premium Member
    Join Date
    Dec 2008
    Posts
    61
    Vote Rating
    0
    jeroenooms is on a distinguished road

      0  

    Default


    Quote Originally Posted by Animal View Post
    Try
    Code:
    Ext.lib.Ajax.useDefaultHeader = false;
    Doesn't do the trick Still 405.

  10. #10
    Ext JS Premium Member
    Join Date
    Dec 2008
    Posts
    61
    Vote Rating
    0
    jeroenooms is on a distinguished road

      0  

    Default


    Quote Originally Posted by Animal View Post
    Also , use disableCaching: false
    I at least get a response from the server:
    I don't get it... if I do the same request it is completely ignored. I just get the XHR Object, no actual request is being made: