gpt4 book ai didi

javascript - 如何将表格内容发送到 Controller

转载 作者:行者123 更新时间:2023-11-29 14:44:10 29 4
gpt4 key购买 nike

我在将表全局从 View 发送到 Controller 时遇到问题 Controller 中的表已满但在 Controller 中影响表的组合为空这是 Controller 方法:

public Boolean ajoutermodule(string nom, modules[] global, int cv)
{
return true;
}

这是 View 和方法 ajax 我如何附加我的全局表以及我如何将这个全局表从 View 发送到 Controller :

function Addmodule() {
var nom = $("#nomprojet_I").val();
var cv = global.length;
$.ajax({
url: "/Module/ajoutermodule",
type: "POST",
dataType: 'json',
data: {
"nom": nom,
"global": global,
"cv": cv,
},
success: function (responseText) {
debugger;
if (responseText == "True") {
alert("Succes");
}
else {
alert("error");
}
}
});

}

var global = [];
function OnGetSelectedFieldValues(s, e) {
var SelectedUsers = $("#teamlist_I").val() + " " + $("#teamid_I").val();
listbox.AddItem(SelectedUsers);


var nom = $("#teamlist_I").val();

var id = $("#teamid_I").val();
global.push({ "id": id, "nom": nom });
debugger;

}

当我添加长度时,它会将他正确发送到 Controller 。

最佳答案

但是方法 ionic 你的 Controller 是这样的: public Boolean ajoutermodule(string nom, stirng s, int cv) { 返回真;

并将其添加到您的方法 ajax 中

var s = JSON.stringify(global);

function Addmodule() {
var nom = $("#nomprojet_I").val();
var s = JSON.stringify(global);
var cv = global.length;
$.ajax({
url: "/Module/ajoutermodule",
type: "POST",
dataType: 'json',
data: {
"nom": nom,
"s": s,
"cv": cv,
},
success: function (responseText) {
debugger;
if (responseText == "True") {
alert("Succes");
}
else {
alert("error");
}
}
});

}

它会起作用的

关于javascript - 如何将表格内容发送到 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34676397/

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