On 20 Feb, 18:58, "mosesdinaka... @gmail.com"
<mosesdinaka... @gmail.comwrote :
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.implem entation.create Document(blah,b lah,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.XMLHT TP"); - for MSIE
requester.open( "GET"...
just amend the javascript to something like:
requestor.open( "POST",URL,asyn c);
reqestor.setReq uestHeader('Con tent-type','applicat ion/x-www-form-
urlencoded');
(if your using async, set a callback)
requestor.send( 'posted=somethi ng&othervar=4') ;
HTH
C.