I want to ignore the fields to the json array if a particular field is null or blank. I am doing the null validation insdie the json object which is currently throws error. Kindly advice how do i ignore a null field to the json object.
var requestType = $("#requestType").val();
var requestorName = $("#requestorName").val();
var requestorDept =$("#requestorDept").val();
var requestorLocation =$("#requestorLocation").val();
var data = {
if(requestType!=undefined && requestType!=null && requestType !='')
{
"RequestType" : requestType,
}
if(requestorName!=undefined && requestorName!=null && requestorName!='')
{
"RequestorName" : requestorName,
}
"RequestorDept" : requestorDept,
"RequestorLocation" : requestorLocation
}
I am getting the error as below
SyntaxError : missing ) after formal parameters
if(requestType !=undefined && issueType !=null && issueType !='')