I have a AJAX request where I would like to pass data based on if condition.
data: testobj
is a JSON object that will return {"name":"tom"}
$.ajax({
type: "POST",
url: 'test.asp',
data: testobj,
success: function(response){
alert(response);
}
});
the data might sometimes be undefined or null. so i'm looking to have something like this
if (testobj != undefined){
data: testobj
}
Is this possible to have this condition without duplicating the whole block ?