ajax 设置 multipart/form-data,如何在ajax中发送multipart / form-data请求

以下功能不起作用。我想上传多个文件&请求由ajax提交。内容类型出现“text / plain; charset = UTF-8”我想更改内容类型=“multipart / form-data”

以下功能如下所示.plz提供任何建议

function importNow(serverURL, parameters) {

document.body.style.cursor = "wait";

$.ajax({

url: serverURL,

data: parameters,

processData: false,

contentType: false,

type: "POST",

cache: false,

dataType: "text",

success: function(data) {

if ($.trim(data) === "Success") {

updateStatusMessage("success", "Import scenario successfully");

} else {

updateStatusMessage("failure", $.trim(data));

}

document.body.style.cursor = "default";

},

async: false

});

}

function importScenario() {

var serverURL = homeURL + "/runapp";

var parameters = "requestType=Import&subRequestType=importScenario&userName=" + userName ;

refButton = '

' +

'' +

'

';

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()) {

parameters;

importNow(serverURL, parameters);

$(this).dialog("close");

}

},

'Cancel': function() {

$(this).dialog("close");

}

}

});

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值