gpt4 book ai didi

javascript - 如何在表单中设置内容类型?

转载 作者:行者123 更新时间:2023-11-28 00:54:50 26 4
gpt4 key购买 nike

这里我需要在表单提交时设置contenttype="multipart/form-data",但它失败了,它分配了contenttype="text/html"如何更改?

refButton = '<form id="importForm" action="http://localhost:8080/bwsim/UploadScenario" class="userInputForm" enctype="multipart/form-data">' +
'<input id="file" name="file" type="file" />' +
'</form>';
document.getElementById("popupDiv").innerHTML = refButton;
$("#popupDiv").dialog({
title: "Import Scenario",
draggable: true,
bgiframe: true,
modal: true,
width: 500,
heigth: 100,
show: {effect: 'blind', duration: 500},
hide: {effect: 'fade', duration: 1000},
zIndex: 1000,
buttons: {
'Upload': function() {
if ($("#importForm").valid()) {
document.forms["importForm"].submit();
$(this).dialog("close");
}
},
'Cancel': function() {
$(this).dialog("close");
}
}
});

最佳答案

its fail it's assign contenttype="text/html" how to change?

不,不是。

您的表单没有 method 属性,因此默认为 GET。

GET 请求没有请求正文,因此没有内容来描述其内容类型。

method="POST" 添加到表单开始标记。

关于javascript - 如何在表单中设置内容类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26340344/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com