I have noticed that I\'m having problems when I\'m using AJAX in jQuery inside a .each() loop. Only the first record in my database are being updated when the script execute
There are a couple things happening here.
By re-using the request variable in the loop (scoped outside the loop), every iteration of the loop assigns a new object to request, overwriting what was there. This means you are only setting the response handlers for the last iteration.
Your request.done method reloads the page, which in practice will halt the other requests and...
You are looking up the same userTypeId for each iteration of the loop, as mentioned by @Sean