tags:

views:

51

answers:

2

hi,

how can I print the content of a php variable on screen if the code is inside a function that is called without refreshing the page, but just to store same values in the database ?

thanks

A: 

AJAX is the only solution. Javascript on the client calls the server, retrieves the value, and updates the necessary DOM object in the displayed page. Beyond doing a form submission (eg POST) or a page retrieval (eg. GET), there's no other way for PHP to affect what goes on in a page once it's been retrieved/displayed.

Marc B
what about using a header function forwarding to the same website, and somehow passing the value ?
Patrick
Header function? Forwarding? makes no sense. Maybe expand your question to detail exactly what you want.
Marc B
A: 

There are there solutions here:

  1. AJAX: Like Marc explained.
  2. An iFrame: where you can have the form submission going through the iframe.
  3. Comet: reverse-AJAX. Unlike AJAX, Comet doesn't require XMLHTTP requests.
Omar