【发布时间】:2017-03-24 11:19:57
【问题描述】:
我正在处理一个带有联系表单的项目,但我的 PhpStorm 或 jQuery 给了我一个非常烦人的警告:
未解析的函数或方法 done()
我尝试过this solution,因为它看起来非常相似,但对我不起作用。也许是因为那个帖子和问题是从 2014 年开始的。
我有这个 ATM:
.done(function(data) {
/*some code*/
});
done 函数始终显示此警告。该功能和我所有的整个联系表格都运行良好,但很烦人。
有人对此有更新的修复吗?因为我知道它为什么这样做,因为阅读了这样的帖子,但他们的修复仍然没有为我做。
我知道这可能是重复的。但是之前的修复可能已经过时了。我希望你明白这就是我创建这篇文章的原因。
编辑
.done(function(data) {
// here we will handle errors and validation messages
if (!data.success) {
// handle errors for name ---------------
if (data.errors.name) {
$('#name').parent().parent().addClass('has-error'); // add the error class to show red input
$('#name').parent().parent().append('<div class="help-block alert-danger">' + data.errors.name + '</div>'); // add the actual error message under our input
}
// handle errors for email ---------------
if (data.errors.email) {
$('#email').parent().parent().addClass('has-error'); // add the error class to show red input
$('#email').parent().parent().append('<div class="help-block alert-danger">' + data.errors.email + '</div>');
}
// handle errors for phone ---------------
if (data.errors.phone) {
$('#phone').parent().parent().addClass('has-error'); // add the error class to show red input
$('#phone').parent().parent().append('<div class="help-block alert-danger">' + data.errors.phone + '</div>');
}
// handle errors for comments ---------------
if (data.errors.comments) {
$('#comments').parent().parent().addClass('has-error'); // add the error class to show red input
$('#comments').parent().parent().append('<div class="help-block alert-danger">' + data.errors.comments + '</div>');
}
if (data.errors.error) {
$('#contact-form').append('<div class="help-block alert-danger">' + data.errors.error + '</div>'); // add the actual error message
}
}
else {
// ALL GOOD! just show the success message!
// empty all inputs
// feedback.show()
$('#contact-form').append('<div class="alert alert-success pull-left collapse">' + data.message + '</div>');
}
});
我看到有些人投票决定关闭它,因为它应该是一个错字。钩子在我的代码中。所以这不是一个错字。
我的问题是如何修复显示标题中提到的错误的警告。
【问题讨论】:
-
你在声明的最后漏掉了一个“)”..
-
添加完整代码
-
ok。会给我一点时间。我希望这里没有错别字。
-
@H.Brendan 很高兴听到这个消息。好的,我会说的。
标签: javascript jquery phpstorm webstorm