- 方式一---普通ajax请求
$.ajax({
url: url,
type: 'POST',
data: {"id":rewardId,"expireDate":expireDateUpdate,"orderNumStr":orderNum,"effectDate":effectDateUpdate},
dataType: "json",
success: function (data) {
if (data.code == 200){
//成功代码
} else {
}
}
});
- 方式二---from表达提交上传文件
var url = "/upload";
var fromdata = new FormData($('#channel-form')[0]);
$.ajax({
url: url,
type: 'POST',
data: fromdata,
contentType: false,
processData: false,
success: function (data) {
if (data.code == 200){
var img_url=data.data;
$("#activityImgUrl").val(img_url);
swal({
title: "图片上传成功"
});
} else {
swal({
title: data.message
});
$("#activityImgUrl").val("");
}
}
});
- 方式3--提交from表单
//序列换from表单,获取数据
var jsonData = $('#channel-form').serializeObject();
//对数据进行操作
if(jsonData["channelCity"] instanceof Array){
}else{
var city = jsonData["channelCity"];
var cityArray = [];
cityArray[0] = city;
jsonData["channelCity"] = cityArray;
}
jsonData["identityList"] = identityData;
jsonData["rewardList"] = rewardData;
//发起请求
$.ajax({
url: "/gr/channel/save",
type: "post",
data: JSON.stringify(jsonData),
contentType: "application/json;charset=utf-8",
success: function (data) {
//返回数据,操作
if (data.code == 200) {
} else {
}
}
});