当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - I'm looking to send information from my PHP script to the client using AJAX. What is the optimal transmission form?

问题描述:

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?

分享给朋友:
您可能感兴趣的文章:
随机阅读: