1、字符串
$.ajax({
type: "POST",
data: {"ID":id,"name":name},
url: "/XX/XXX/XXXX",
cache: false,
success: function (result) {
if (result > 0) {
alert("保存成功!");
}
else {
alert("保存失敗,請稍後再試!");
}
}
});ajax
後臺 XXXX(string ID,string name){} //ID、name json
2、實體類this
var data = {};
data["ydayScheduleCount"] = $("#ydayScheduleCount").val();
data["ydayRealCount"] = $("#ydayRealCount").val();
data["ydayCancelCount"] = $("#ydayCancelCount").val();
data["ydayDelayCount"] = $("#ydayDelayCount").val();
data["ydayDelayTwoCount"] = $("#ydayDelayTwoCount").val();
data["ydayFlightNormalRate"] = $("#ydayFlightNormalRate").val();
data["ZBAAScheduleCount"] = $("#ZBAAScheduleCount").val();
data["ZBAARealCount"] = $("#ZBAARealCount").val();
data["ZBAACancelCount"] = $("#ZBAACancelCount").val();
data["ZBAADelayCount"] = $("#ZBAADelayCount").val();
data["ZBAADelayTowCount"] = $("#ZBAADelayTowCount").val();
data["ReMarkA"] = $("#ReMarkA").val();
data["ReMarkB"] = $("#ReMarkB").val();
data["ReMarkC"] = $("#ReMarkC").val();
data["ReMarkD"] = $("#ReMarkD").val();
data["ReMarkE"] = $("#ReMarkE").val();
data["ReMarkF"] = $("#ReMarkF").val();
$.ajax({
type: "POST",
data: data,
url: "/XX/XXX/XXXX",
cache: false,
success: function (result) {
if (result > 0) {
alert("保存成功!");
}
else {
alert("保存失敗,請稍後再試!");
}
}
});url
後臺 XXXX(CpyNightNew gnn){} //gnn 實體類orm
3、集合字符串
var _list = {};input
for (var air in airport) {
_list["runinfo_airport_racc[" + air + "].Airport"] = airport[air];
_list["runinfo_airport_racc[" + air + "].ActualCount"] = $("#" + airport[air] + "_ActualCount_Z").val();
_list["runinfo_airport_racc[" + air + "].NormalRate"] = $("#" + airport[air] + "_NormalRate_Z").val();
_list["runinfo_airport_racc[" + air + "].Delays"] = $("#" + airport[air] + "_Delays_Z").val();
_list["runinfo_airport_racc[" + air + "].ProblemCauses"] = $("#" + airport[air] + "_ProblemCauses_Z").val();
_list["runinfo_airport_racc[" + air + "].Days_Type"] = "Z";
_list["runinfo_airport_racc[" + air + "].isair"] = 1;
}string
$.ajax({
url: '/XX/XXX/XXXX',
data: _list,
dataType: "text",
type: "POST",
traditional: true,
success: function (responseJSON) {
if (responseJSON > 0) {
alert("更新成功!");
}
else {
alert("更新失敗,請稍後再試!");
}
}
});it
後臺 XXXX(List<runinfo_airport_racc> runinfo_airport_racc) //runinfo_airport_racc 集合io
4、json
//獲取整表數據
function GetAllTableDate() {
var tr = $("#tb_duty").find("tr");
var week = 1;
var arraySaveDate = new Array();//存放數據的list
var objDate = new Object;//存放數據的每一個model
var arr = ["onduty_name", "onduty_title", "onduty_contract", "onduty_week", "onduty_group"];
$.each($(tr), function () {
var tdArr = $(this).children();
objDate.onduty_name = tdArr.eq(1).find("input").val();//值班領導
objDate.onduty_title = tdArr.eq(2).find("input").val();//職務
objDate.onduty_contract = tdArr.eq(3).find("input").val();//聯繫方式
objDate.onduty_week = week;
objDate.onduty_group = 0;
arraySaveDate.push(objDate);
objDate = new Object();
objDate.onduty_name = tdArr.eq(4).find("input").val();//值班領導
objDate.onduty_title = tdArr.eq(5).find("input").val();//職務
objDate.onduty_contract = tdArr.eq(6).find("input").val();//聯繫方式
objDate.onduty_week = week;
objDate.onduty_group = 1;
arraySaveDate.push(objDate);
objDate = new Object();
objDate.onduty_name = tdArr.eq(7).find("input").val();//值班領導
objDate.onduty_title = tdArr.eq(8).find("input").val();//職務
objDate.onduty_contract = tdArr.eq(9).find("input").val();//聯繫方式
objDate.onduty_week = week;
objDate.onduty_group = 2;
arraySaveDate.push(objDate);
objDate = new Object();
week++;
});
return JSON.stringify(arraySaveDate);
}
function save(isSave)
{
$.ajax({
type: "POST",
dataType: "text",
url: "/ShareMethod/SaveDutyPlan",
data: { "strDutyPlan": GetAllTableDate(), "isSave": isSave },
success: function (result) {
alert(result);
}
})
}
後臺
public string SaveDutyPlan(string strDutyPlan,bool isSave){
//頁面傳遞數據集
List<onduty_info> lst_onduty_info = JsonConvert.DeserializeObject<List<onduty_info>>(strDutyPlan);
}