Reputation: 15866
script
$(document).ready(function () {
var meter_id = $("#MeterReadingTypes li a.link_active").attr("id");
var range_id = $("#DateRangeTypes li a.link_active").attr("id");
window.setInterval(PostMainChartValues(meter_id, range_id), 5000);
...
});
function PostMainChartValues(meter_id, range_type_id) {
$.ajax({
...
});
}
window.setInterval is not trigerred. If I write an alert in setInterval it works. What is the reason of this? Why function is not triggering? I tracked it with chrome DevTools, and there is no move.
Upvotes: 0
Views: 1429
Reputation: 113375
This is not an ajax issue. You are using in wrong mode the setInterval
parameter.
Create an anonymous function
like bellow:
window.setInterval(function () { PostMainChartValues(meter_id, range_id); }, 5000);
Upvotes: 0
Reputation: 66663
The first parameter to setInterval
should be a function (or an eval
able string). Right now, you are calling PostMainChartValues()
and passing its return value to setInterval()
.
Change it to:
window.setInterval(function() {
PostMainChartValues(meter_id, range_id);
}, 5000);
Upvotes: 3