I'm in the process of learning React/javascript, so apologies if this is a simple question & answer. In short; I have a function within a React class that needs to be called on the success of an AJAX call (which is also nested inside another function in the same class).
Here is the example code:
var Bar = React.createClass({
fooBar: function() {
this.setState({
step : this.state.step + 1
})
},
submitRegistration: function() {
$.ajax({
url : "something",
type: "POST",
data : data,
success: function(data, textStatus, jqXHR) {
Bar.fooBar()
}
});
}
}
I have tried the following with no success:
Bar.fooBar()
this.fooBar()
How can I call the fooBar() method from within the success AJAX method?