【问题标题】:Ember-data ie9 post requests not workingEmber-data ie9 发布请求不起作用
【发布时间】:2016-04-29 20:34:15
【问题描述】:

我正在使用ember-data 2.4.0ember-ajax 2.0.1 并且遇到了ie9 问题。我读到 ie9 使用旧的 XDomainRequest 而不是新的 XHR 请求,并且它只发送空白或text/plain 内容类型。我有一个 ember-data 发布到的 rails api,它在 Chrome、Firefox 和 ie10+ 上运行良好,但在 ie9 中我可以看到有效负载没有使用 json 内容类型发送,所以服务器只是得到一个纯文本字符串,它不被识别为期望 json 数据的参数散列。

有人建议我做这样的事情,但它对我不起作用。

export default DS.JSONAPIAdapter.extend({
  host: ENV.apiUrl,

  ajaxOptions(url, type, hash) {
    hash.contentType = 'application/json';
    hash.dataType = 'json';

    return this._super(url, type, hash);
  }
});

所有的 store 请求都是标准的this.store.create('whatever', payload) 类型的请求。

Ember 的文档说它在 ember 2+ 中支持 ie9,所以我认为这可以开箱即用。我是否遗漏了一些东西来完成这项工作?

【问题讨论】:

  • ember-data 4.2.0 不存在,我假设您的意思是 2.4.0?
  • 是的,我的错,那是节点版本。

标签: ajax ember.js ember-data internet-explorer-9


【解决方案1】:

我通过在 app/index.html 文件中添加此 XDomainRequest polyfill https://github.com/MoonScript/jQuery-ajaxTransport-XDomainRequest 解决了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-21
    • 2023-03-17
    • 2015-11-13
    相关资源
    最近更新 更多