For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > February 2007 > What is the difference between Ajax POST and GET









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author What is the difference between Ajax POST and GET
mosesdinakaran@gmail.com

2007-02-20, 6:59 pm


Hi Everybody,

As all knows the difference between GET and POST is in the way how
the data is transfered,

But in case of ajax Though it may be a post Request we need to
format a querystring manually and send with the url,

My question is there any other way that without sending the query
string can we get the post values as in a normal form submit.


regards
Moses

Jerry Stuckle

2007-02-20, 6:59 pm

mosesdinakaran@gmail.com wrote:
> Hi Everybody,
>
> As all knows the difference between GET and POST is in the way how
> the data is transfered,
>
> But in case of ajax Though it may be a post Request we need to
> format a querystring manually and send with the url,
>
> My question is there any other way that without sending the query
> string can we get the post values as in a normal form submit.
>
>
> regards
> Moses
>


Check out CURL.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Satya

2007-02-21, 7:00 pm

On Feb 20, 11:58 pm, "mosesdinaka...@gmail.com"
<mosesdinaka...@gmail.com> wrote:
> Hi Everybody,
>
> As all knows the difference between GET and POST is in the way how
> the data is transfered,
>
> But in case of ajax Though it may be a post Request we need to
> format a querystring manually and send with the url,
>
> My question is there any other way that without sending the query
> string can we get the post values as in a normal form submit.
>
> regards
> Moses


I only see difference when you retrieve data in PHP/servers side.
i.e $_POST and $_GET.

Rik

2007-02-21, 7:00 pm

On Wed, 21 Feb 2007 15:36:29 +0100, Satya <satya61229@gmail.com> wrote:

> On Feb 20, 11:58 pm, "mosesdinaka...@gmail.com"
> <mosesdinaka...@gmail.com> wrote:
>
> I only see difference when you retrieve data in PHP/servers side.
> i.e $_POST and $_GET.


That is not entirely true.
A GET request has al it's values in the requested url in the protocol.
This means it's limited in size. A POST request has the POST values in the
body of the request. This means a difference in formatting the data.

--
Rik Wasmus
C.

2007-02-21, 7:00 pm

On 20 Feb, 18:58, "mosesdinaka...@gmail.com"
<mosesdinaka...@gmail.com> wrote:
> Hi Everybody,
>
> As all knows the difference between GET and POST is in the way how
> the data is transfered,


No - there is a difference in how its transfered but there are several
syntactic and semantic differences.

>
> But in case of ajax Though it may be a post Request we need to
> format a querystring manually and send with the url,
>
> My question is there any other way that without sending the query
> string can we get the post values as in a normal form submit.
>

Yes - although:
1) it's nothing to do with PHP
2) it won't work everywhere

If you post (pvar=3) to a url with a query (http://www.example.com/?
gvar=splodge) the relevant variables will appear in the _POST and _GET
arrays. All variables will appear in _REQUEST.

If you look at you javascript which actualy makes the request it will
typically decide at runtime whether to create a document or use
xmlhttprequest.

If it does something like this:

requestor = document.implementation.createDocument(blah,blah,blah);

then you can't (AFAIK) post.

if on the other hand it does this:

requestor = new XMLHttpRequest(); - for a sensible browser
requestor = new ActiveXObject("Microsoft.XMLHTTP"); - for MSIE
requester.open("GET"...

just amend the javascript to something like:
requestor.open("POST",URL,async);
reqestor.setRequestHeader('Content-type','application/x-www-form-
urlencoded');
(if your using async, set a callback)
requestor.send('posted=something&othervar=4');

HTH

C.

C.

2007-02-21, 7:00 pm

On 21 Feb, 15:05, Rik <luiheidsgoe...@hotmail.com> wrote:
>
> That is not entirely true.
> A GET request has al it's values in the requested url in the protocol.
> This means it's limited in size. A POST request has the POST values in the
> body of the request. This means a difference in formatting the data.
>


IIRC the HTTP protocol does not limit the size or a URL - but MSIE
does (to about 2kb)

C.

mosesdinakaran@gmail.com

2007-02-23, 8:00 am

Thanks Colin and to All.

Moses

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com