tags:

views:

36

answers:

1

Hi,
I want to know what is the best way to send data from web browser to server using post method.
I've seen a practice where they wrap all the elements data in XML, convert it into Base64 string and then post it to the server (via Ajax or hidden field).
this way will not work if the Javascript is disabled, any how if I ignored this.
is it a good practice to wrap elements into XML (or create my custom wrapper in general) and post them to server saying it will enhance the maintainability of the code or just stick with the classical way and no need to add unnecessary text in the post.

+3  A: 

I'd suggest using the traditional JSON data interchange format for the posted data. Mature languages all have support for it, e.g. PHP has json_encode to pass anything back from the server as well.

JavaScript libraries like jQuery make all this incredibly easy and guaranteed to work cross-browser.

IMHO, in many occasions XML will bloat the data stream with markup overhead, esp. for short chunks of data, e.g. of a numeric kind.

Ain