I'm trying to solve the following:
I have two methods within my Component:
getData requests the data and gets approximate time when the results will be ready.
I want to set setTimeout for that delay and than pass the request id to method processData, which makes another request to retrieve the actual data using the request id it got from requestData I am trying to access.
I am unable to reference the processData from within setTimeout in ajax's success.
How to do that? I've tried this.processData, this.refs., processData without success.
var Component = React.createClass({
processData: function(id) {
// ajax gets the data using the id (which we got from sending the request in requestData)
},
requestData: function(colid) {
$.ajax({
url: "/api/getvalues/id/"+colid,
type: "GET",
cache: false,
dataType: 'json',
success: function(data) {
setTimeout(function() {this.refs.processData(data.id);}, data.estimatedWaitTime+250);
}
});
}
});