I have the following function:
$(function(){
performance();
function performance(){
pHandler = setTimeout(performance,3000)
perOb = [];
alert('hhhh')
$(".performance").each(function(i){
perOb[i] = $(this);
url = '/cavity/performance/'+perOb[i].attr('data-id')+'/'+jobId;
//perOb[i].html('%');
$.ajax({
type: "GET",
//dataType: "json",
url: url,
success: function(data){
perOb[i].html(data.performance+"%");
},
error: function(xhr, status, response){
console.log(xhr.responseText);
},
});
});
}
});
I'm trying to call it from another event like the following:
$('#in-between').change(function(){
if ($(this).prop('checked')){
window.clearTimeout(pHandler);
alert('yesr')
}
else{
alert('noo')
performance();
}
})
I have got the error performance is not a function
. I have tried $.performance()
, jQuery.performance()
and also I have tried to assign it to a variable like:
perf = $(function(){
performance();
function performance(){
pHandler = setTimeout(performance,3000)
.......
And calling it as perf.performance()
but all of those trying don't succeeded to call it from the event.
This question is differ than JavaScript error: "is not a function" for the following:
It is meant by Jquery so someone may, mistakenly, regard that multiple
document.ready(function())
as one scope for Jquery