class Form {
ajax(method = '', dtype = '', path = '', data = '') {
$.ajax({
type: method,
dataType: dtype,
url: path,
data: getstarteddata,
success: function(res) {
if (res == 200) {
$("#btnsend").attr("disabled", true).val("Subscribed");
$(".sucess-message").text('Way to go π');
} else {
$("#btnsend").attr("disabled", false).val('Subscribe');
$(".error-message").text('oops! failed try β')
}
},
error: function (res) {
$(".error-message").text('OMG! β β '+ JSON.stringify(res));
return false;
}
});
}
grabmail(email = ''){
if (email.split("@").length != 2) {
$("#btnsend").attr("disabled", false).val('Subscribe');
$(".error-message").text('uhmm! email not right')
} else {
this.ajax('POST', 'json', './app/newslater', {mail: email});
}
}
submit(){
$("#newslatter").on('submit', function(e) {
e.preventDefault();
let email = $(".email-input").val();
this.grabmail(email);
})
}
}
form = new Form();
form.submit();
I get Uncaught TypeError: this.grabmail is not a function. Iβm not sure, whatβs wrong