search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Update multiple Event to server in loop

Asked by Thomas Lee
2 years ago.

I have DayPilot.Scheduler having multiple events.
I need to update real Event ID after handle from Server, Server will return the real Event ID
I will replace EventID from ui() with Event Id from Server.
But I have a problem that, not all the Events in Scheduler are updated.

Here is my code:

var Events =;
if (Events.length > 0) {
for (var i = 0; i < Events.length; i++) {
var CurrentEv =[i].id);
type: "POST",
async: true,
url: Url,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
if (response.length == 3) {

if (response[0] !== "" && response[1] !== "") {
value = 1;
/* Update Client-side */
for (var i = 0; i <; i++) {
var e =[i];

if ( == response[0]) { = response[1];

/*2018/04/07: replace Bubble-HTML */
e.bubbleHtml = e.bubbleHtml.replace(, response[1]);


} else {
}, error: function (response) {
dpPrdPkg.message("Approve Event FAILED " + response.text);


Thank in advance,
Thomas Lee

Answer posted by Dan Letecky [DayPilot]
2 years ago.

If you have 300 events in events.list this code will fire 300 HTTP requests which will complete in more or less random order. In the success callback, you are requesting a full update() - the update is partially asynchronous and it will not work properly if you modify events.list before it finishes.

Try replacing this logic with a single HTTP request and a single update() call.

This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.