You can save the link to external this:
var that = this;
$.get(APIURL, function (data) {
that.setState({resdata: "This is a new state"});
});
Or use $.proxy:
$.get(APIURL, $.proxy(function (data) {
this.setState({resdata: "This is a new state"});
}, this));
thiswhich you use inside the function usually refers to the jqXHR object, ref http://api.jquery.com/jquery.ajax/
source
share