Vous devez vous assurer que vous ne définissez pas le state.recordId
encore et encore chaque fois que vous exécutez la fonction qui appelle la méthode .ajaxPoll()
. state = ...
devrait être dans un champ parent de la fonction qui fonctionne .ajaxPoll()
peut-être quelque chose comme ceci:
(function() { // <== Our scope
// set the value to 1 only once!
var state = {
recordId: 1
};
// The function that runs the poll. Do not set recordId to 1 inside here!
var callPoll = function() {
$.ajaxPoll({
url: "map-service.cfc?method=getpoints",
type: "POST",
data: state, // state.recordId will be 1, 2, 3, ...
dataType: "json",
successCondition: function(location) {
// return result != null; // custom condition goes here.
// increment it by 1
state.recordId = state.recordId +1
alert(state.recordId)
}
});
};
$(function() { // <== on doc ready
// Your functionality etc...... for example:
setInterval(callPoll, 1000);
});
}()); // <== Execute the anonymous function we're using as our scope