PDA

View Full Version : send query string onClick


vandenberg
12-20-2002, 10:08 PM
Hi!

I have a button, and when the user clicks on it, I want to call an url, but don't want to open it. (I want to pass a variable to a php file. So: I don't want to open the page, I just want to call it)

<INPUT TYPE="text" value="click here" onMouseDown="callUrl('http://server.com/index.php?var1=val1">

callUrl is of course pseudo code/ pseudo function. Is there, however, any way to do this? (work around would work aswell)

Tell me if you don't understand what my problem is :o


thanks

beetle
12-20-2002, 10:29 PM
Use this in your PHP<?php

header("HTTP/1.0 204 No Content");

?>Before sending any other headers or output.

vandenberg
12-20-2002, 10:41 PM
I don't understand what you mean.

I need a normal html page with javascript in it to 'call' an php. Then the php file processes the query string.
But my problem is solely how to call that url. If I do window.location.href or something, the location of the page changes. I want it to call an Url only however..

Do you understand? Maybe the question is a little bit strange...

vandenberg
12-20-2002, 10:45 PM
I think I found an workaround, but it's really not elegant. Maybe you even understand better what I need now.

<img src="http://server.com/file.php?var1=yes" width="1" height="1">

that way, i have an broken image, but I manage to call an url.. It's not really elegant.. Isn't there any way in javascript of doing this? Just calling an url, but not opening it

beetle
12-20-2002, 10:51 PM
You can't do that with javascript. The type of interaction you are looking for requires HTTP headers (which javascript cannot set)

The 204 HTTP response header means 'no response', so the page is accessed by the server, but sends no response to the browser.

Here's (http://www.webmasterbase.com/article/314/7) some good reading for you :D

vandenberg
12-20-2002, 10:54 PM
thanks :)

vandenberg
12-20-2002, 10:55 PM
that site is really good, thanks for the link