I want to send a variable to server with getJSON function in jquery.
y = "some data";
if (con == true) {
t = "brand";
}
else {
t = "type";
}
$.getJSON('url', { t: y }).done(function (data) {
alert(data);
});
in the server side i have function for each information that send with getJSON. for example when i use brand
instead of t
, the brand()
function in the server side called and when i send type
instead of t
, type()
function in the server side called.
t
variable is different in some case.for example the value of t
variable in one case is equal to brand
and in another case is equal to type
.how i can use value of t
,instead of t
in this case?