gpt4 book ai didi

jquery - 如何将多选中的值数组传递到 jquery ajax 调用中?

转载 作者:行者123 更新时间:2023-12-01 04:49:19 24 4
gpt4 key购买 nike

我正在使用 jQuery multiSelect 并希望将选择传递到我的更新脚本。

这是我的 ajax 调用

var newnotesecurity = $("#nt_newnotesecurity").serializeArray();

$.ajax({
url: 'notes-savenewnote.php',
method: 'POST',
data: {
cache: false,
companyid: companyid,
entitytype: entitytype,
entityid: entityid,
noteinitials: newnoteinitials,
notetext: newnotetext,
notetags: newnotetags,
notesecurity: newnotesecurity
},
success: function() {
// blah
},
error: function(){
// blah
}
});

nt_newnotesecurity 是多选对象。显然,serializeArray 不适合我。这只是我为实现此目的所做的最新尝试。

我最终传递了这个:

notesecurity[0][name]=nt_newnotesecurity&
notesecurity[0][value]=2&
notesecurity[1][name]=nt_newnotesecurity&
notesecurity[1][value]=14

但是我想传递这个

nt_newnotesecurity=2&nt_newnotesecurity=14

或者我会满足于传递一个稍后可以爆炸的值,就像这样

notesecurity=2-14

最佳答案

根据documentation对于多选插件,只需调用 val() 即可获取所有值

var newnotesecurity = $("#nt_newnotesecurity").val();

关于jquery - 如何将多选中的值数组传递到 jquery ajax 调用中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23548541/

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