I'm trying to pass dynamically keys for data
option into ajax call.
data:{action:'add',id:10},
Actually I'm trying to create global function, which can be use for all tables for disable the specific rows onClick
event. For that purpose I need to add different actions and table column names for calling php function. So i want to pass keys also as well as values.
JS Function
function globalDisable(id,table_column,call_action){
// call_action is use for calling the related php function
// table_column is use for calling the column name of that table
action_parm = {call_action:'disable',table_column:id}
$.ajax({
type:'POST',
url:'post.php',
data:action_parm,
success: function(response){
}
});
}
Call JS Function
onclick="return globalDisable(10,'user_id','disableUser');"
Php Script
$disableUser = (isset($_REQUEST['disableUser']))? (string)$_REQUEST['disableUser']:'not';
if($disableUser != 'not'){
$response->disArea($user_id);
}
When I run the function, in console doesn't changing its remains same call_action=disable&table_column=10
.
So is this possible to pass dynamically keys for data option in ajax call? I would like to appreciate if someone guide me regarding this. Thank You