I am sending a form with AJAX and everything works fine, the problem is that I need to store the AJAX response in an Angular2 variable.
My code:
xhr.onreadystatechange = function(e) {
this.miVariableAngular = this.responseText;
};
Error:
The error arises because the program believes that when using this.myVariableAngular I am calling an AJAX method, since it confuses the THIS variable variable with the THIS reference to the AJAX response .
How can I assign that answer in a variable of angular 2?
I thank you in advance for your collaboration,