Comments (4)
from ajax.
对于你提的这个问题,我查了关于ajax的设计方案level1和level2的规范。因为首先在**当前的开发版本和环境中,ie10之前的版本 都必须兼容的,而在level1的方案中是这样说的:不能发送二进制文件(如图片、视频、音频等),只能发送纯文本数据。这个纯文本就是字符串。level2的方案应该已经支持了,我要做个全面的测试一下
from ajax.
对于level2的测试也做过了。下面是总结:
- 在ajax方案中,只要不是发送二进制数据都是纯文本文件,所以后台接受的都是String类型的数据。你看到有些后台语言中能够将简单json转换为类的数据,是后台语言在request请求中做了一层简单的语法封装。但是对于足够复杂的json数据(数组中有json,json中有数组),这就必须自己处理
- 处理这类数据的方案正常一般都是在前端传输的时候做处理的,否则后台接受到的数据就是[object object]这一种,因为后台语言明确上的基础数据类型都没有json这个类型。一般的解决方案就是将前端的复杂数据进行JSON序列,JSON.stringify(数据),比如你提供的数据就可以改成{ a : 213,b : JSON.stringify([ {c : 132} ])},然后就可以通过ajax将数据发送到后台,后台接收到b这个数据进行反序列化映射成可读的class数据,在之前开发的项目中,我记得好像,我们就是这样前端封装,后端反序列化得到数据的。
from ajax.
忘了补充最根本的一点:对于json,本质上就是字符串,只是在前端转成对象了。
from ajax.
Related Issues (9)
- 长轮询返回的数据是字符串吗,可以像jquery一样定义返回‘json’参数属性吗 HOT 1
- 提了一个PR,作者可以看下 HOT 1
- 关于原生ajax的错误提出 HOT 5
- 跨域真的能实现? HOT 2
- 兄弟,错别字啊 HOT 1
- 长轮询如何取消操作呢? HOT 1
- ajax.1.9.js文件与微信jweixin-1.2.0文件会导致冲突 HOT 4
- async:false无效 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ajax.