I am making a system, and in it I need to send several data to the server, basically synchronize an array of objects on a server via json using javascript, until there is no problem, however the request is $ .ajax, which is asynchronous, and therefore, I can not control the data later, nor save the data at the end of the execution of all the requests.
I have done with a for, and found on the net, first that could use async: true, however, I also saw that this function was deprecated, so one should use promise or callback, but both could not implement, there are some example how can I do this?
Edited to clarify the problem
consistency, since it is an array of data that may or may not already be in the database, so I use the id (which the database provides) to find out if the object is registered, if there is an id in the object, p>
But returning to the main, what happens is that when sending a data to the server, the asynchronous call of $ .ajax, if put so that in each success the data is saved, this results in that in some cases, the result end ends up being information with and without the id. resulting in unexpected behavior. this is why ajax calls, because they are asynchronous, do not end in series, and in parallel being each one in its time.