AJAX可以传输什么数据格式? [英] What data formats can AJAX transfer?

查看:528
本文介绍了AJAX可以传输什么数据格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的AJAX,但作为一个概述,我想知道是什么格式,你可以上传和下载。是不是仅限于JSON或XML或者你甚至发送二进制类型,如MP3或UTF-8 HTML。最后,你有完全控制数据,就像一个字节数组字节一个字节,或者是只派一个字符串/接收。

I'm new to AJAX, but as an overview I'd like to know what formats you can upload and download. Is it limited to JSON or XML or can you even send binary types like MP3 or UTF-8 HTML. And finally, do you have full control over the data, byte for byte in something like a byte array, or is only a string sent/received.

推荐答案

如果我们谈论的AJAX我们正在谈论的JavaScript?而关于XMLHTT prequest?

If we are talking about ajax we are talking about javascript? And about XMLHTTPRequest?

在XMLHtt prequest这仅仅是一个HTTP请求可以传递一切。但是,在JavaScript中没有字节数组。只有字符串,数字和这样。你从一个Ajax调用得到每一件事情是一段文本(responseText的)的。这可能被解析成XML(它给你reponseXML)。特殊的编码应该是HTTP传输的更多的事情。

The XMLHttpRequest which is only a http request can transfer everything. But there is no byte array in javascript. Only strings, numbers and such. Every thing you get from an ajax call is a piece of text (responseText). That might be parsed into XML (which gives you reponseXML). Special encodings should be more a matter of the http transport.

二进制的东西是不是阿贾克斯依赖,但依赖的JavaScript。有一些怪异编码为字符串提供内的JavaScript(尤其是图像)字节的数据,但它不是一个通用的解决方案。

The binary stuff is not ajax dependent but javascript dependent. There are some weird encodings for strings to deliver byte data inside in javascript (especially for images) but it is not a general solution.

HTML是不成问题的,而且是最突出的用例。从这种类型的请求你提供的HTML字符串,并且被添加到每个的innerHTML的DOM的解析HTML一些节点。

HTML is not a problem and that is the most prominent use case. From this type of request you get an HTML string delivered and that is added to some node in the DOM per innerHTML that parses the HTML.

这篇关于AJAX可以传输什么数据格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆