私は次のコードにいくつかの条件変数があります。たとえば、var shipping == "true"の場合、shippingAddress1、shippingAddress2などが存在します。しかし、shipping == "false"の場合、これらの変数は未定義であり、空白のままです。私の問題は、投稿しようとすると、いくつかのvarsが未定義であるため、jsエラーが発生することです。これらを空白で送る方法はありますか?投稿が有効になるようにAJAXの未定義変数を変更する
$.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
},
を使用すると、フォームフィールドを探している場合は、[シリアル化](http://api.jquery.com/serialize/) – epascarello