gpt4 book ai didi

javascript - 从数据表传递多个数组值

转载 作者:行者123 更新时间:2023-11-28 03:57:49 26 4
gpt4 key购买 nike

目前我正在使用具有多重选择的数据表。当我根据 picture here 选择 3 行时(从上到下),我的 console.log 返回 this value (每次选择行时返回结果)。我需要发布到下一页的值是这个,因为它是最新结果:

["SN20171110", "SN20171111", "SN20171113"]

所以我再次执行console.log来检查ajax post中的值,而没有进入下一页,但结果是随机的(顺序):

/image/zVkrW.png

/image/Irf1k.png

/image/9Nn1n.png

所以我在下一页中得到的是上面提到的 console.log 的底部(最新)结果。

有没有办法只传递底部结果或javascript变量?

这是我的数据表选择代码:

  var newdata = $.map(example.rows('.selected').data(), function (item) {
$(this).toggleClass('selected');
return item[1];
});

var test = newdata;
console.log(test);

$('#nextButton').click(function(e){
$.ajax({
url : 'enrollmentDevice.php',
method : 'POST',
data : { test },
beforeSend: function(){
console.clear();
},
success : function(new2) {
console.log(test);
}

提前致谢。

最佳答案

好的,我通过将值发布到隐藏表单并使用 POST 到下一页来解决问题

<form action="nextpage.php" method="POST"></form>

而不是使用 Ajax。但仍不确定是什么原因导致问题。任何意见将不胜感激。谢谢。

关于javascript - 从数据表传递多个数组值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47414826/

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