I have an onClick
function which works as expected. Once this function has been triggered once by click, I want to run it periodically using setInterval
.
Here is how I have modified the code to attempt this:
var clickData;
var isClicked=0;
function onClick(e) {
console.log("OnClick called")
if(isClicked==0){
clickData = this;
isClicked = 1;
console.log(clickData);
}
let empID = clickData.options.empID;
let reqURL = baseurl + API_KEY + "&MonitoringRef=" + empID;
$.ajax({
type: "GET",
dataType: "jsonp",
url: reqURL,
success: success2,
});
}
if(isClicked==1){
var f = onClick;
f.paramater1 = clickData;
setInterval(f, 500);
}
function success2(json2){
console,log(json2);
//Do something with json2...
}
I have modified the calling of the function from setInterval
according to one to one of the answers here.
I think the problem here is with passing the parameters to the function. Is there a way of achieving this?