我试图搜索解决方案,但找不到任何适合我的代码。
我的网站上有很多不同的类别。在尝试添加新广告here is the link时。
form.find('.info-tooltip-container').addClass('hidden');
var firstErrorMessageTop = form.find('.error-tooltip-container, .main-form-error').first().offset().top;
if (!form.hasClass('ajax-form-no-scrolling')) {
$(window).scrollTop(firstErrorMessageTop - 10);
}
}
if (response.status == 'success') {
if (callback == 'addCallBack') {
window[callback](response.aid, response.step);
}
else if (callback == 'editCallBack') {
window[callback](response.aid);
}
}
});
所有其他类别的工作正常,Category: Job » IT / telecom / computers
除外。当我尝试发送时出现错误:
Uncaught TypeError: Cannot read property 'top' of undefined
有人可以告诉我出了什么问题吗?
答案 0 :(得分:0)
您没有提供软件信息,但是从屏幕截图中显示错误Uncaught TypeError: Cannot read property 'top' of undefined
来自文件release.js?v=2
行65
。
因此,通过查看源代码,问题来自于该行:
var firstErrorMessageTop = form.find('.error-tooltip-container, .main-form-error').first().offset().top;
所以可能offset()
在这里返回undefined,请尝试检查
var firstErrorMessage = form.find('.error-tooltip-container, .main-form-error').first();
var firstErrorMessageTop = firstErrorMessage && firstErrorMessage.offset() && firstErrorMessage.offset().top ? firstErrorMessage.offset().top : 0;