开发者

What is the best way to post data from web browser to server?

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 no开发者_开发问答t 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜