我有以下 javascript:
var User;
(function (User) {
(function (AccessControls) {
User.AccessControls.loginFormSubmit();
function loginFormSubmit() {
$('#article').on('submit', '#loginForm form', function () {
var $form = $(this);
if(!$form.valid()) {
return false;
}
var myData = $form.serialize();
var myUrl = $form.attr("action");
return false;
});
}
AccessControls.loginFormSubmit = loginFormSubmit;
})(User.AccessControls || (User.AccessControls = {}));
var AccessControls = User.AccessControls;
})(User || (User = {}));
//@ sourceMappingURL=loginFormSubmit.js.map
我得到的确切错误是:
Uncaught TypeError: Object #<Object> has no method 'loginFormSubmit'
谁能解释为什么我会收到这个错误?
如果有帮助,这是我的打字稿代码:
module User {
export module AccessControls {
loginFormSubmit();
export function loginFormSubmit() {
$('#article').on('submit', '#loginForm form', function () {
var $form = $(this);
// if there are validation errors do not continue.
if (!$form.valid()) {
return false;
}
// get the form data
var myData = $form.serialize();
// get the url to post to from the form's action attribute.
var myUrl = $form.attr("action");
// execute the post
//$.ajax({
// url: myUrl,
// data: myData
//success: function(data) {
// // on success, write the returned article content into the article element
// $('#article').html(data);
//}
return false;
});
}
}
}