Giter VIP home page Giter VIP logo

Comments (4)

GerryIsWarrior avatar GerryIsWarrior commented on June 5, 2024

from ajax.

GerryIsWarrior avatar GerryIsWarrior commented on June 5, 2024

对于你提的这个问题,我查了关于ajax的设计方案level1和level2的规范。因为首先在**当前的开发版本和环境中,ie10之前的版本 都必须兼容的,而在level1的方案中是这样说的:不能发送二进制文件(如图片、视频、音频等),只能发送纯文本数据。这个纯文本就是字符串。level2的方案应该已经支持了,我要做个全面的测试一下

from ajax.

GerryIsWarrior avatar GerryIsWarrior commented on June 5, 2024

对于level2的测试也做过了。下面是总结:

  1. 在ajax方案中,只要不是发送二进制数据都是纯文本文件,所以后台接受的都是String类型的数据。你看到有些后台语言中能够将简单json转换为类的数据,是后台语言在request请求中做了一层简单的语法封装。但是对于足够复杂的json数据(数组中有json,json中有数组),这就必须自己处理
  2. 处理这类数据的方案正常一般都是在前端传输的时候做处理的,否则后台接受到的数据就是[object object]这一种,因为后台语言明确上的基础数据类型都没有json这个类型。一般的解决方案就是将前端的复杂数据进行JSON序列,JSON.stringify(数据),比如你提供的数据就可以改成{ a : 213,b : JSON.stringify([ {c : 132} ])},然后就可以通过ajax将数据发送到后台,后台接收到b这个数据进行反序列化映射成可读的class数据,在之前开发的项目中,我记得好像,我们就是这样前端封装,后端反序列化得到数据的。

from ajax.

GerryIsWarrior avatar GerryIsWarrior commented on June 5, 2024

忘了补充最根本的一点:对于json,本质上就是字符串,只是在前端转成对象了。

from ajax.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.