I want to check some user inputs with an if statement and depending on them, specify some parameters to send as an ajax request.
My approach doesn't work at all. It's just not valid code:
$.ajax({
method : "GET",
url : "test.php",
data :
if (...) {
a: "abc",
b: "def"
}else{
b: "ghi",
c: "jkl"
},
success : function(data) {
console.log(data)
},
error : function(data) {
console.log(data);
}
});
Does anybody have a better idea?