var type = $(this).attr("data-type");
var typeId = $(this).attr("data-value");
if(type=="category") var typeVar="cat";
else if(type=="subcategory") var typeVar="subcat";
$.ajax({
url: 'admin-catalog/next',
type: 'POST',
dataType: 'json',
data: {typeVar: typeId, limit: 9},
success: newGalleryProducts
});
The key ‘typeVar’ in my ‘data’ key needs to be dynamic, i.e. it should not post ‘typeVar’ as the key, it should post either ‘cat’ or ‘subcat’.
Anybody know how to do this?
If you want to do it within the
datakey, you can do such way:Or like @archil metioned, use
JSON.parsemethod: