Welcome Guest, Not a member yet? Register   Sign In
Parallel sessions using ajax fail
#1

[eluser]N.S.G.[/eluser]
Hi everyone,

I'm having some trouble with sessions. My situation is as follows: I have a number of expandable divs, and I want to keep track of the ones expanded by the user. So I'm using a session and a jquery-ajax request to save data to the session.

The problem is that multiple ajax requests are fired at that same time, and one of them also tries to save data to the session. I've noticed that most of the time, the second session save does work, and the first one doesn't.

Now I've done some digging through the session class and I think what happens is that both requests get the original session data, add the new variable and save the session, but since the requests are parallel (and they start out with the same data) only one of the new variables will be saved with its new session.

Now, is there any way to fix this without merging my requests to one? I found this article (http://ellislab.com/forums/viewthread/102456/) but that's not what's happening here, because my problem happens all the time, even when the session is brand new.

Thanks in advance!
#2

[eluser]pickupman[/eluser]
How about posting some code...view perhaps, your ajax request? It's hard to give any advice without some code. I will mention that if the first request needs to complete before the second, then you should be using a callback in jquery to do this. Fire first event, once completed, then fire second event in the success callback.




Theme © iAndrew 2016 - Forum software by © MyBB