【问题标题】:Append array element to FormData doesn't work in Firefox 15将数组元素附加到 FormData 在 Firefox 15 中不起作用
【发布时间】:2023-03-22 07:53:01
【问题描述】:

我正在发出跨域 ajax 发布请求。 有客户端功能:

function getUsersData()
{
  var ids = ["user1_id", "user2_id"];
  var fd = new FormData();
  $.each(ids, function() {
    fd.append('identities', this);
  });
  var xhr = new XMLHttpRequest();
  xhr.open('POST', 'http://some-domain.com/Home/GetUsersData', true);
  xhr.withCredentials = true;
  xhr.onreadystatechange = responseHandler; //function is defined and not shown here
  xhr.send(fd);
}

在 Opera 和 Google Chrome 浏览器中一切正常。 但是 Firefox 在 fd.append('identities', this);

它可能是什么以及如何解决此错误?

【问题讨论】:

    标签: javascript ajax post xmlhttprequest cross-domain


    【解决方案1】:

    尝试使用唯一键。类似于:fd.append('identity-'+this.id, this);

    【讨论】:

      猜你喜欢
      • 2013-11-03
      • 2017-02-25
      • 2020-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-30
      • 2021-07-04
      • 2020-12-03
      相关资源
      最近更新 更多