0

How do I send an HTTP GET request without a form? This request is performed on a web page.

For more details on what I'm trying to accomplish and why, see my question here: http get/post request and google geolocation api

Community
  • 1
  • 1
  • What are you trying to accomplish might help to refine this question. – cgp Apr 14 '09 at 18:39
  • please see my other question found here... http://stackoverflow.com/questions/745217/http-get-post-request-and-google-geolocation-api –  Apr 14 '09 at 18:42

6 Answers6

8

Any link is a GET request, so, just make a link, add the extra info at the end, done.

http://someurl.net/somelink?value1=avalue&value2=anothervalue

James Black
  • 41,583
  • 10
  • 86
  • 166
2

A normal hyperlink does a GET request when the user clicks on it. Loading an image is also a GET request, as are most of the other ways of embedding things in a page. If you're trying to do it via JavaScript, you can use an XMLHttpRequest.

rmeador
  • 25,504
  • 18
  • 62
  • 103
1

You can use Ajax and jQuery's get method:

$.get("someURL.php?variables=true");

Note, that you will only be able to make requests to the same domain OR the target domain must return JSON formatted results.

cgp
  • 41,026
  • 12
  • 101
  • 131
1

In plain HTML you can do that e.g. requesting an image:

<img src="http://example.com/?bla=bla">
vartec
  • 131,205
  • 36
  • 218
  • 244
1
< a href="www.google.com">google</a>
Warrior
  • 39,156
  • 44
  • 139
  • 214
1

I agree with altCognito points out using jquery but I'd rather use

$.get("someurl.php", { variable: value });

I like this way better because it allows me to send objects instead of concatenate strings. you can see a couple of samples here

Eugenio Miró
  • 2,398
  • 2
  • 28
  • 38