You are here: Re: What is the difference between Ajax POST and GET « PHP Programming Language « IT news, forums, messages
Re: What is the difference between Ajax POST and GET

Posted by C. on 02/21/07 17:27

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.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация