Page 1 of 1

submitting GET info without reloading ?

Posted: Tue Jul 16, 2002 4:46 am
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.

Posted: Tue Jul 16, 2002 5:33 am
by twigletmac

Posted: Tue Jul 16, 2002 6:28 am
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.

Posted: Tue Jul 16, 2002 6:51 am
by galena

Posted: Tue Jul 16, 2002 7:32 am
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.

Posted: Tue Jul 16, 2002 9:35 am
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......

Posted: Tue Jul 16, 2002 8:38 pm
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

Posted: Tue Jul 16, 2002 11:59 pm
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

Posted: Wed Jul 17, 2002 2:52 am
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" />

Posted: Wed Jul 17, 2002 11:23 am
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.