Page 1 of 1

Ajax POST and GET.

Posted: Tue Jan 30, 2007 7:21 pm
by JellyFish
Hey, I'd like to elaborate on the differences in using POST or GET method for your HTTP requests with javascript's XMLHttpRequest object. For all I know, at the moment, the difference in that with php you'd use $_POST with POST methods and $_GET with GET methods.

Please explain in detail the concept, I'm a little confused on this on.

Thanks for reading.

Posted: Tue Jan 30, 2007 7:27 pm
by Kieran Huggins
it's all about how / if you send data with your request.

When you do a GET request, you're only sending the URL, which can pass some limited data in it.

A POST request can send a whole chunk of data with it. Some people send XML, others send form encoded data.

General rule of thumb: If you're getting a update or something, use GET. If you're submitting data, use POST.

jquery has these functions built in, and their descriptions might help clear things up: http://www.visualjquery.com/1.1.1.html

Posted: Tue Jan 30, 2007 7:35 pm
by JellyFish
So which method would you recommend for a login form and a simple error message (like "Forgot to enter your password")?

Posted: Tue Jan 30, 2007 7:39 pm
by superdezign
I'm sure login is always best to use post, regardless of your medium. Would you want your login information on screen as a friend walks by?

Posted: Tue Jan 30, 2007 7:53 pm
by Kieran Huggins
I don't think it really matters with small data like that, but I almost exclusively use POST anyway.

Posted: Tue Jan 30, 2007 8:04 pm
by JellyFish
Okay, is there any difference syntactically with POST?