我有这个代码:
function myFunction(serializeData, extraSerializedData){
//serializeData is boolean
var formSerializedData = '';
if(serializeData){
var formSerializedData = $("#myform").serialize();
if (typeof extraSerializedData !== 'undefined'){
formSerializedData += extraSerializedData;
}
}
$.ajax({
type: "get",
url: "/123",
data: formSerializedData, //TODO!!!
success: function(data){
//......
我只想在存在的情况下添加data
密钥serializeData
。是否有可能以及如何以使代码保持“美丽”的方式做到这一点?