简体   繁体   English

Internet Explorer要求下载POST请求作为下载

[英]Internet Explorer asks to download POST request as a download

I have inherited a PHP script that does a lot of logic with in-url POST. 我继承了一个PHP脚本,该脚本在URL内POST中具有很多逻辑。 Once we make the request within IE9, it asks the user for a download of type "true" with a size that closely resembles the POST request. 一旦我们在IE9中发出请求,它就会要求用户下载“ true”类型的下载,其大小与POST请求非常相似。 At no point do we see any behavior where the data isn't being saved on the server -- the expected behavior after submit is to simple ask for a download. 我们从来没有看到任何没有将数据保存在服务器上的行为-提交后的预期行为是简单地要求下载。

The actual POST call is being fired using jQuery.ajax: 使用jQuery.ajax触发了实际的POST调用:

$.ajax({
  type: "POST",
  url: "profile/edit-profile-info.php",
  data:"mail="+mail,
  success: function() {
    console.log('Success!!!');
    location.reload('true'); //Reloads the page with the form
  }
}).done(function() {
    console.log('Done!!!');
    location.reload('true'); //Reloads the page with the form
});

And the reload command is inherited within the browser object space, from what I can tell. 据我所知,reload命令是在浏览器对象空间中继承的。

The actual PHP script that handles this data essentially saves the data in an ORM (not in the code) and returns a request as text/plain 处理此数据的实际PHP脚本实际上将数据保存在ORM中(不在代码中),并以文本/纯文本形式返回请求

header('Content-Type: text/plain; charset=utf-8');
$data->record->mail = $_POST['mail'];

We tried sending another Content Type as a request and it fails to function in Chrome, Firefox, et al. 我们尝试发送另一种内容类型作为请求,但它无法在Chrome,Firefox等中运行。

Looking at the inherited HTML, the fields are populated in a hierarchy without a form tag, which gives me pause as to that being the cause. 查看继承的HTML,这些字段填充在没有form标签的层次结构中,这使我停下来。 I'm not entirely sure if that's a culprit. 我不确定这是否是罪魁祸首。 Unfortunately I can't readily give out a demo for review. 不幸的是,我不能轻易给出演示供审查。 But if anyone has seen this or has any ideas on the cause, insight would be appreciated. 但是,如果有人看到了这个原因,或者对原因有任何想法,则将不胜感激。

Remove the commas around true in location.reload('true'); 删除location.reload('true');中围绕true的逗号。 it requires a boolean and your inputting it as a string which is not what IE is expecting. 它需要一个布尔值,并且您将其作为字符串输入,这不是IE期望的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM