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

余生长醉 提交于 2019-12-18 05:08:05

问题


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

Where is my mistake?

Ext.getVersion()

version: "5.0.1.1255"


回答1:


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');
  }
});


来源:https://stackoverflow.com/questions/27682785/sencha-extjs-cannot-send-post-request-on-cross-domain-with-ext-ajax-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!