Ruby on rails IE11上的FormData接口问题
您好,我使用FormDataWebAPI收集FormData,并通过Ajax将其发送到RubyonRails后端。 一切正常,但我在IE11中遇到了一个问题 问题: *如果我编辑表单,但没有名字,并选中“男性”单选按钮,则请求被中断 *即使我没有编辑表单,也可以将其发送为空 标记示例:Ruby on rails IE11上的FormData接口问题,ruby-on-rails,internet-explorer-11,form-data,Ruby On Rails,Internet Explorer 11,Form Data,您好,我使用FormDataWebAPI收集FormData,并通过Ajax将其发送到RubyonRails后端。 一切正常,但我在IE11中遇到了一个问题 问题: *如果我编辑表单,但没有名字,并选中“男性”单选按钮,则请求被中断 *即使我没有编辑表单,也可以将其发送为空 标记示例: <form action="/"> <label for="input-1">Name</label> <input type="text" name="inp
<form action="/">
<label for="input-1">Name</label>
<input type="text" name="input-1" value="">
<label>
<input type="radio" name="radio-1" value="male"/>
<span>Male</span>
</label>
<label>
<input type="radio" name="radio-1" value="female"/>
<span>Female</span>
</label>
<button name="button" type="submit">submit</button>
</form>
请尝试按以下方式修改您的代码:
<form action="/">
<label for="input_1">Name</label>
<input type="text" name="input_1" value="">
<label>
<input type="radio" name="radio_1" value="male"/>
<span>Male</span>
</label>
<label>
<input type="radio" name="radio_1" value="female"/>
<span>Female</span>
</label>
<button name="button" type="submit">submit</button>
</form>
更多信息,请参阅以下文章:
及
<form action="/">
<label for="input_1">Name</label>
<input type="text" name="input_1" value="">
<label>
<input type="radio" name="radio_1" value="male"/>
<span>Male</span>
</label>
<label>
<input type="radio" name="radio_1" value="female"/>
<span>Female</span>
</label>
<button name="button" type="submit">submit</button>
</form>
var data = new FormData();
//you could use JavaScript script to get the value from the input elements.
data.append("filesToDelete", "Value");
data.append("clientContactId",
(clientContactId != undefined || clientContactId != null) ? clientContactId : ''));
$.ajax({
type: "POST",
url: "/api/FileAttachment/UploadFiles",
/* ONLY IF YOU ARE UPLOADING A FILE
contentType: false,
processData: false, */
dataType: "JSON"
data: data,
success: function (result) {
},
error: function (xhr, status, p3, p4) {
}
});