0

I need to send a request via GET but ExtJS changes the method for OPTIONS

I changed useDefaultXhrHeader even though I could not send, I also need to disable CORS

https://fiddle.sencha.com/#view/editor

Ext.application({
name: 'Fiddle',

launch: function () {
    Ext.Ajax.request({
        url: 'http://localhost:8888/api/sign/certificates',
        method: "GET",
        useDefaultXhrHeader : false,
        headers: {
            'Content-Type': 'application/json',
            'Access-Control-Allow-Origin': '*'
        },

        success: function (response, opts) {
            var obj = Ext.decode(response.responseText);
            console.dir(obj);
        },

        failure: function (response, opts) {
            console.log('server-side failure with status code ' + response.status);
        }
    });

}
});

PRINT

Elvis Reis
  • 129
  • 2
  • 8
  • 1
    You are trying to access `http://localhost:8888/api/sign/certificates` from a webpage hosted on `https://fiddle.sencha.com`, which is a Cross-Origin request. [The browser sends a preflight request with Options method for cross-origin requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS). Also, check the fiddle link you have posted. – CS. Jun 09 '17 at 17:14
  • Sorry for my question, but is there any way I can get around this with $ .ajax I can make the request – Elvis Reis Jun 09 '17 at 17:52
  • 1
    Possible duplicate of [How to disable OPTIONS request?](https://stackoverflow.com/questions/29954037/how-to-disable-options-request) – scebotari66 Jun 09 '17 at 19:58

1 Answers1

-1

I think you want to eliminate the _dc cache parameter, you can do it like this

noCache: false,

Use this in your Ext.Ajax.request({})

Hope this helps!!