Hi,
How do I pass a variable as a key in a key/value pair in Ajax?
For example, this does NOT work:
function DoAjaxCall(columnname, value) {
$.post(_callerquery, {
columnname: value
}, function(data, textStatus) {
alert(data+ ' '+ textStatus);
}, 'json');
}
DoAjaxCall('LASTNAME', 'Jackson');
It keeps posting the columnname as "columnname" instead of
"LASTNAME");
JQuery somehow treats all keys as strings and not as variable.
I know I can do something like this, but it's not what I'm after:
function DoAjaxCall(columnname, value) {
$.post(_callerquery, {
thecolumnname: columnname,
thevalue: value
}, function(data, textStatus) {
alert(data+ ' '+ textStatus);
}, 'json');
}
thanx, Bart