My onClick
function is functioning correctly. However, I want to run it periodically using setInterval
after it's been triggered by a click event. Here's my attempt at modifying the code:
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 made changes to calling the function from setInterval
based on one of the solutions found here.
The issue seems to be related to passing parameters to the function. Is there a solution for this?