I want to make a sorting function in ajax but the sorting function can be enable or disable by the user
I tried to pass a variable when user clicks a button, however the ajax still using the old variable
Is it possible to do it?
我想在ajax中创建一个排序函数,但是当用户点击一个按钮时,我尝试传递变量的用户可以启用或禁用排序功能,但是ajax仍然使用旧变量是否可以这样做?
Here is my code
这是我的代码
var sort_or_not = "true";
function click_button_to_not_sort_test()
{sort_or_not = "false";}
//function to make my ajax not sort?
function approve_edit()
{
$('#approve_table').dataTable({
"processing": true,
"paging":false,
"bPaginate":false,
"bFilter": false,
"scrollY": 300,
"info": false,
//"bSort" : false,
"aoColumnDefs": [
{ 'bSortable': sort_or_not, //This is the variable that i want to to passed from the button click
'aTargets': [ 0, 1, 2,3 ]
},
{ 'width': "15%",
'aTargets': [ 0, 2, 3]
}
],
"ajax": "approve_table.php?approve=1"
});
1 个解决方案
#1
0
Don't put true
or false
in quotes. So first lines should be:
不要在引号中加上真或假。所以第一行应该是:
var sort_or_not = true;
function click_button_to_not_sort_test() {
sort_or_not = false;
}
#1
0
Don't put true
or false
in quotes. So first lines should be:
不要在引号中加上真或假。所以第一行应该是:
var sort_or_not = true;
function click_button_to_not_sort_test() {
sort_or_not = false;
}