我有以下代码:
function postToDrupal(contacts, source, owner) {
(function ($) {
var contact, name, email, entry;
emails = {};
for (var i = 0; i < contacts.length; i++) {
contact = contacts[i];
emails[i]['name'] = contact.fullName();
emails[i]['email'] = contact.selectedEmail();
}
$.post("/cloudsponge-post",emails,function(data) {
});
}(jQuery));
}
当我尝试运行它时出现以下错误:
WARN: Attempt to invoke callback [afterSubmitContacts] failed: TypeError: Cannot set property 'name' of undefined
我不确定问题是什么——我对 JS 很陌生,发现它有点棘手。它坏了的原因是什么,我该如何修复它?