My experience with TypeScript is still fresh, and I've encountered an issue while trying to call a function within the same class. Here's the function in question:
createPost(url: String, data: any) {
$.ajax({
url: url + "/" + GLOBAL.REGISTER_URL,
type: "POST",
data: data.serialize(),
success: function() {
console.log("success");
},
error: function(request, status, error) {
console.log(request.responseText);
console.log(status);
console.log(error);
}
});
}
I'm attempting to invoke it here:
.on('success.form.bv', function(e) {
$('#success_message').slideDown("slow"); // Do something ...
$('#contact_form').data('bootstrapValidator').resetForm();
// Prevent form submission
e.preventDefault();
// Get the form instance
var $form = $(e.target);
// Get the BootstrapValidator instance
var bv = $form.data('bootstrapValidator');
// Reassigning port for testing purposes only
var result = "https://" + window.location.hostname + ":" + GLOBAL.PORT + "/" + GLOBAL.VERSION + "/rest" + GLOBAL.REGISTER_URL;
this.createPost(result, $form);
});
Unfortunately, this doesn't seem to be working as expected. Every time I click the button, I encounter an error in the browser:
ERROR TypeError: this.createPost is not a function Stack trace: ../../../../../src/app/register/register.component.ts/RegisterComponent.prototype.ngOnInit/<@http://localhost:4200/main.bundle.js:839:13 (error details)
Calling this function should be straightforward, but I'm puzzled by what could be causing this issue. Any assistance would be greatly appreciated.