问题描述:

I have five separate, although related, strings of text which I need to transfer from the server (PHP) to the client (JS). I intend to use AJAX, but I've only ever used AJAX for transmitting a single line of plain text.

So, I'm wondering what options I should explore, XML, JSON, etc. in order to best transfer the information, and how to prepare/receive the information.

网友答案:

It is easy in PHP to convert data types over to JSON, via json_encode.

XML is only slightly more cumbersome, in that you have to generate the DOMDocument yourself.

There is a breakdown of the pros/cons here: What are the pros and cons of XML and JSON?

相关阅读:
Top