Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sencha ExtJS. Cannot send POST request on cross-domain with Ext.Ajax.request

I have backend with POST functionality (so JSONP is not working). Backend sends Access-Control-Allow-Origin: * correctly (jQuery.ajax works successfully). But I cannot send request using Ext.Ajax.request

Ext.Ajax.request({
  url: 'http://myurl',
  method: 'POST',
  cors: true,
  success: function () {
    alert('success');
  },
  failure: function () {
    alert('failure');
  }
});

In debug console I see OPTIONS method

enter image description here

Where is my mistake?

Ext.getVersion()

version: "5.0.1.1255"

like image 568
indapublic Avatar asked Dec 29 '14 02:12

indapublic


1 Answers

I think you will have to set useDefaultXhrHeader to false also in your ajax request,like below.

Ext.Ajax.request({
  url: 'http://myurl',
  method: 'POST',
  cors: true,
  useDefaultXhrHeader : false,
  success: function () {
    alert('success');
  },
  failure: function () {
    alert('failure');
  }
});
like image 73
dReAmEr Avatar answered Nov 04 '22 16:11

dReAmEr