I have a need to pass the variable value as a name in the below function using [tokenName] for CSRF purposes. It works fine in Firefox and Chrome, but not IE11.
The error I get is: Expected identifier, string or number on the [tokenName] line.
Thoughts?
$('#container').on('click','#delete',function(e) {
e.preventDefault();
var button = $(this),
form = button.closest('form'),
id = button.attr('data-id'),
verify = button.attr('data-verify'),
tokenName = form.find('input[name=token_name]').val(),
tokenHash = form.find('input[name=' + tokenName + ']').val();
// delete user via ajax
$.post(form.attr('action'), {
"id" : id,
"object" : verify,
[tokenName] : tokenHash
}, function(data) {
// do stuff
}, "json");
});