javascript - Modifying array with asycronus data -


I have a very curious problem, I'm sure nobody in the world has come to know. Let's keep the simple thing. OK here we go.

So I have a simple array of objects. For now, 5 objects are called. {Id: 1, data: 'stuff'}, {id: 2, data: 'stuff'}, {id: 3, data: 'stuff'}, {id: 4, data: 'stuff'}, {id : 5, data: 'stuff'}]

Then what do I do 3 Ajax requests that all come back, obviously, and are different times What I want to do is update this ARD based on ID. For example, I send 3 AJAX requests and get new data for object 1, 2 and 4. I have to update the data property in the related objects in the array. I'm using Array.splice to update. What I know is happening several times, because the data comes at different times, these things are not updated correctly. I think this is because what makes a wedding, actually removes the object from the array, and then later incorporates the new array again. It appears that there are instances where the sacrifice method is between the removal of an object, then another reaction comes and tries to remove another object, however, this object is not in the correct index, because first If the object was removed and not included in yet, then the update is closed.

There is no need to change an array, you are at all trying to update the objects within the array Apart from this, the pointer should not make any difference because you are using the id property to identify each object specifically, not the index in the array.

Whatever methods you should use, to loop through the array, find and update the object with the related id .


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Algorithm negotiation fail SSH in Jenkins -

java - Messages from .properties file do not display UTF-8 characters -