tags:

views:

70

answers:

2

I am using jquery to set a session, i have a php page which gets the values of the person logging. The value in the session array, is then used in another page where, it is stored in a hidden field for database entry.The problem is, the value is not set unless you refresh the page of which beats the purpose of AJAX and Jquery.Again,the session seems to be one session behind.How can I do this without page refresh/ reload?

A: 

It sounds like you are doing this...

1) User types some stuff in

2) AJAX requests fires that stuff off to the server

And it sounds like you need to add:

3) Using the result of step 2, set the value on the current page

Sohnee
Yes that is what am ive done but the session will not be set until the current page is refreshed.
John
Of which i want to avoid.Any help please
John
A: 

ok, so if I get this straight, you use ajax to let a user log in on one page, and on another page you want some magic value from the session to be filled in? Is this other page already open at the point the user logs in? e.g:

  1. user opens two windows, one to "loginpage.php" and the other to "formpage.php"
  2. user logs in, data sent to server via ajax, magic value created in session
  3. user switches to "formpage.php" window, fills in the form there, and submits
  4. server expects magic value to be returned in hidden field, but it's not there

something like that? If that's the case, there's no way for the "formpage" window to know that you've logged in via the other window. The server can't 'push' a login notification to it, and generally javascript in one window can't affect the contents of another window, unless that window was created by the first window to begin with.

You could have the "Formpage" window poll the server to see if the user's logged in via another window, and then request this magic value and dynamically fill in the hidden field. But otherwise you'd have to refresh the page to get that hidden form field filled in.

Marc B