我正在編寫一個函數來發送$ .post顯示請如何正確地將變量插入對象,具體取決於它們是否設置。 這裏是我想要做的:
function SendCommand(Command, QuestionId, Attr) {
$.post('/survey/admin/command',
{
'Command': Command,
if (QuestionId) 'QuestionId' : QuestionId,
if (Attr) 'Attribute' : Attr
}
);
}
謝謝!
這是最短的 – alega