submitting GET info without reloading ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
galena
Forum Newbie
Posts: 7
Joined: Tue Jul 16, 2002 4:46 am
Location: Netherlands

submitting GET info without reloading ?

Post by galena »

Hi,

Is it possible to submit info to a PHP script without reloading the current page.

I want to create a link with some GET variables, and the if people click the link, the GET info will be submitted, but the current page just stays on.

I want to do this because the page my visitor is looking at, is a large table in the backend of a database. Reloading it is unnecessary and costly.

Thanks, Michiel.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

galena
Forum Newbie
Posts: 7
Joined: Tue Jul 16, 2002 4:46 am
Location: Netherlands

Post by galena »

Well yeah, I have read this. Maybe I misstated the question. I know it is not possible directly, but there is probably a workaround.

I know that the old audiogalaxy site was doing a similar thing. You could click on the satellite button, then the button would turn green, and the corresponding song was added to your queue, but the page was never reloaded. The button color was changed using javascript, but the song was added to the queue by a PHP script, which was called from a link on the button. However, I was never able to figure out how they did it exactly. Too bad the pages have changed now, otherwise you could take a look.

I will probably try to use a frame with size 0 and load an empty page into it.

Michiel.
galena
Forum Newbie
Posts: 7
Joined: Tue Jul 16, 2002 4:46 am
Location: Netherlands

Post by galena »

User avatar
llimllib
Moderator
Posts: 466
Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD

Post by llimllib »

you could try creating a script that is basically a small TCP server using sockets in PHP, and then your page could send it a request (again using sockets) when the link was clicked. Basically, you'd have to get down and dirty, as I don't see an easy way to do it. Even if this solution is possible (probably) it wouldn't be very stable or scale up to a high volume of users. There's got to be another way, something more clever, but I'll be...ehm...darned... if I can think of it right now.
galena
Forum Newbie
Posts: 7
Joined: Tue Jul 16, 2002 4:46 am
Location: Netherlands

Post by galena »

yeah, I already thought of using an (unvisible) applet, combined with some JavaScript. The point is, I have bad experience messing around with applets and javascript like this. A lot of browsers just won't eat it. Then it would be better just to move everything to a Java program or Java2 applet or so......
User avatar
sam
Forum Contributor
Posts: 217
Joined: Thu Apr 18, 2002 11:11 pm
Location: Northern California
Contact:

Post by sam »

A while back I found a project to call server side scripts and cgi from javascript... I can't for the life of me find the stuff though, I'll keep looking, just letting you know it is possable.

Cheers Sam
ajaypatil
Forum Newbie
Posts: 17
Joined: Wed Jul 03, 2002 2:15 am
Location: Pune, India
Contact:

Post by ajaypatil »

Hi galena,

Let me know if you find a solution to your problem.
I am wondering whether following would work:
- Call a javascript function when the link is clicked.
- Submit the GET info in the javascript function.
- Call the browser back action inside the javascript function
immediately after form is submitted.

Another option, is that once the GET info is submitted,
you can show the next page with message saying info was
submitted successfully.. and a link to go back.
If the user clicks the back link, you direct the browser back action.

Thus, the page will be re-loaded from cache, rather than from
the server.

Does this solve your problem ? Please let me know.

Ajay
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

i say you should use iframes..

Code: Select all

<form name="foo" target="bar"
 <input type="text" name="example" value="blah" />
 <input type="submit" />
</form>

<iframe src="blank.html" name="bar" height="0" width="0" />
galena
Forum Newbie
Posts: 7
Joined: Tue Jul 16, 2002 4:46 am
Location: Netherlands

Post by galena »

I would also say the iframe is the best solution. There are some concerns though, because you're messing up the browser's history, causing some unexpected behaviour on the refresh and back buttons.

Anyone interested, check the oreilly page I posted earlier. They have good solutions.
Post Reply