У меня есть несколько условных переменных в следующем коде. Например, если переменная shipping == "true", тогда существуют shippingAddress1, shippingAddress2 и т. Д. Но, если shipping == "false", эти переменные не определены и оставлены пустыми. Моя проблема в том, что когда я пытаюсь опубликовать сообщение, я получаю сообщение об ошибке js, потому что некоторые переменные не определены. Есть ли способ отправить их через бланк?
$.post( 'reserveAPickupAppointmentCreatePickup.php', {
'location': appointmentLocation,
'appointmentAddress1': appointmentAddress1,
'appointmentAddress2': appointmentAddress2,
'serviceType': serviceType,
'shipping': shipping,
'shippingAddress1': shippingAddress1,
'shippingAddress2': shippingAddress2,
'shippingCity': shippingCity,
'shippingState': shippingState,
'shippingZip': shippingZip,
'startTime': startTime,
'endTime': endTime,
'date': date,
'estimatedSize': appointmentSize,
'highValueItems': highValueItems,
'insuredItems': insuredItems,
'tools': tools,
'presentAtAppointment': presentAtAppointment,
'contactName': contactName,
'contactPhone': contactPhone,
'contactEmail': contactEmail,
'itemList': itemList,
'studentPhone': studentPhone
},