我有registerAjax(e)中函数:e.PreventDefault是未定义
function registerAjax(e) {
e.preventDefault();
let userData = {
username: $("#username").val(),
password: $("#password").val(),
};
$.ajax({
method: "POST",
url: kinveyBaseUrl + "user/" + kinveyAppKey + "/",
headers: kinveyAppAuthHeaders,
data: userData,
success: registerSuccess,
error: handleAjaxError
});
function registerSuccess(userInfo) {
saveAuthInSession(userInfo);
showInfo('User registration successful.');
}
这个功能是通过该功能
function registerUser() {
registerAjax();
当运行应用程序,我收到控制台消息调用“未捕获TypeError:无法读取未定义(...)属性'preventDefault'“
有没有解决此异常的简单解决方案?
function startApplication() {
//Bind The Form Submit Buttons
$(document).ready(function() {
$("#btnRegister").on('click', registerUser());
});
loadingBox();
//Bind the info/error boxes: hide on click
$("#infoBox, #errorBox").click(function() {
$(this).fadeOut();
});
}
为什么当你不通过任何事情时会有事件发生? – Eric
为什么要在undefined上调用preventDefault? –
我是新来的,我怎么才能成功注册用户? –