I want to join the value of field = 'city'
AND '_id'
string. That is to say, city_id
But I want city_id
as a variable for $.post
variable as below :
$.post("jquery_post",{city_id : 8},function(data){........}
Is that possible?
You use array notation to assign or access dynamic property names in an object.
var params = {};
params[field+"_id"] = 8;
$.post("jquery_post", params, function(data){...});