iOS front-end and background interaction technology implementation and technical details

Source: Internet
Author: User

Summary

Today, I give you a technology to share, sharing the theme is that we have no work or to work soon or is in the probation period of the students are very concerned about a problem, is that we do ios,html5, Android and other front-end development of how to interact with our company backstage.
What should we say when facing the background?
How to avoid some of the tasks that should not belong to the background imposed on themselves? And so on.

Directory
    1.前端请求数据URL的谁来写?    2.接口文档主要由谁来写?    3.前端开发与后台交互的数据格式主要是什么?    4.前端开发的后台交互原理?    5.前端请求参数的形式    6.前台应该告知后台哪些有效信息,后台才能返回前端想的数据的呢?    7.我们应该怎么把页面这些信息有效传达给后台呢,以及后台是如何获取到数据的呢?    8.前端应该如何规避一些本不属于自己做的一些功能需求或任务呢?    9. 当前端在调用数据接口时,发现有些数据不是我们想要的,那么前端应该怎么办呢或者怎么跟后台讲呢?

Let's give you a detailed explanation.

1. Who will write the URL of the front-end request data?

  在开发中,URL主要是由后台来写的,写好了给前端开发者.

If the background is querying the data and needs to be queried to query the data needed by the front-end, then the backend will ask the front-end to provide the relevant query parameters, for example:

  select "产品图片","优惠[买2送花茶]","产品名称","商品价格","是否包邮" from tb_goodList where time = “传递过来的参数"  如果 没有后面的查询条件,就会查询到所有的时间的数据,前端则需要的是某一天的数据,这时前端就需要把时间当做参数传递给后台,后台根据这个参数再进行数据查询.返回前端页面需要的数据.例如:  http://www.hehe168.com/goodList.php?time="2016-05-12 00:00:00"
2. Who will write the main interface documents?

接口文档也是主要由后台开发者来写的,因为直接跟数据打交道的就是后台,后台是最清楚,数据库里面有什么数据,能返回什么数据.前端开发只是数据的被动接受者.所以接口文档也主要是由后台来完成的,前端只是接口文档的使用者,使用过程中,发现返回的数据不对,则需要跟后台进行商量,由后台来修改.切记 前端不要随意更改接口文档,除非在取得后台开发人员的同意的情况下.

Generally speaking, the interface document mainly by the background to design, modify, the front-end developers play an auxiliary role.

3. What is the main data format for front-end development and background interaction?


1) The other is JSON (Javascriptobject Notation), which is also a lightweight data transfer format that organizes the data with a bunch of brackets.
Benefits: Unlike binary, this format is human readable, and relatively lightweight, so there are a number of application scenarios. The JSON data format is used for delivery.


2) XML

But the most used in our project is the JSON data format, which is in its general form:
{"Flag": "001", "Content": {}}

4. Background interaction principle of front-end development?


At the time of the project, we will probably say the interface address, front-end request parameters, back-end parameters returned, and then everyone began to write, write the same time, we adjust the interface to look at the data returned, no problem on it.

5. Form of the front-end request parameter


Get and post are the two common methods of HTTPS.
Get-gets data from the specified server
POST-submits data to the specified server for processing

Get method Features:
When you use the Get method, the query string (the key-value pair) is appended to the URL address and sent to the server:
/test/demo_form.jsp?name1=value1&name2=value2
Characteristics:
Get requests can be cached
Get requests are saved in the browser's browsing history
URL with Get request can be saved as browser bookmark
Get request has a length limit
Get requests are primarily used to obtain data

Post method:
When using the Post method, the query string exists separately in the post message and is sent to the server along with the HTTP request:
post/test/demo_form.jsp http/1.1
Host:w3schools.com
Name1=value1&name2=value2
Characteristics:
Post requests cannot be cached
Post requests are not saved in browser browsing history
The URL to post request cannot be saved as a browser bookmark
POST request has no length limit

6. The foreground should inform the backstage which valid information, backstage can return the front-end to think of the data?
    首先,前端要先学会对一个页面展示的数据进行有效的分析,把需要的数据都记下来,然后告知后台.大家看到还是感到很迷惑,我来举一个例子给大家进行详细的解释.看图片:

Take this diagram as an example: we can divide this page into three sections as shown in:

1) 轮播图部分2) 商品种类部分3) 每日推荐部分

Next we will explain the three parts in detail. Please keep looking down.
7. How can we effectively communicate these page information to the background and how to get the data in the background?

1) Carousel Diagram section

The front-end part: My page needs the latest picture address of the product today, the parameters of the URL is mainly based on the background needs, if the background needs to pass a time before the front-end to be able to query the specific picture information, then the front end in the data request parameters should contain the parameters of the time, for example:

  URL:http://www.hehe168.com/GetPicture.php  或者http://www.hehe168.com/GetPicture.php?time="2016-05-12 00:00:00"

Background part: will go to the database to find the corresponding data table, such as the carousel chart, the query condition is the front end passed the URL parameter time for example:

       select “轮播图片” from tb_picture where time = "2016-05-12 00:00:00"
2) part of the product category

Let's analyze this picture of the show.

What does he contain, and does it contain:

1)标题图片2)标题

These content in the background database table design is also a separate database table to store, for the background to query and access to data is very easy. So the background only need to design a URL to the front-end, if you need any auxiliary parameters, the background will directly to the front-end requirements. For example:
URL form:

URL:http://www.hehe168.com/variety.php或者http://www.hehe168.com/variety.php?time="2016-05-12 00:00:00"
3) Daily recommended section

:

Let's take a look at the above figure what it contains:

1)产品图片2)优惠[买2送花茶]  3)产品名称 4)商品价格5)是否包邮

The front end of this information to inform the background, the background to see the information, will go to the corresponding database to query, if the data backstage is easy to obtain, will directly give a URL to the front end. Otherwise, the front end is required to pass some parameters through the URL.
URL form:

URL:http://www.hehe168.com/goodList.php或者http://www.hehe168.com/goodList.php?time="2016-05-12 00:00:00&clases=""
So in general: all front-end request URL after the parameters, are auxiliary background data query. If no parameters are required, then the backend will give the URL directly to the front end.

Good this page analysis finished, we should have a preliminary understanding of it.

8. How should the front end avoid some tasks or functional requirements that are not part of their own?
    在与后台打交道中,我们经常遇到这种情况,有时候明明后台来处理某个事件很简单,后台非要你来做,这时候我们应该懂得去回绝他.
How should we go back to rejecting it?
    这可能对于之前没做过项目,或者没与后台打交道的人来讲非常头痛的事,这就需要我们对一个需求,一个任务的要有清晰认识了,如果对任务含糊不清,自己都没搞明白,你只能受后台摆布了.最后也会因为任务没有完成而备受责难了.在这里就不给大家举例子了.
Faced with such a problem, how should we do it?
 在这里给大家一些建议,也就是在与后台打交道时,不要轻易的承诺,对很多自己熟悉的需求或功能点,自己可以立刻答应下来,对那些模糊不清,记下来,回去百度,看看具体原理是什么,是不是该前端这边去实现或者实现起来非常困难,那么想想后台是否做起来很方面,去跟后台商量.
9. The current end in the call data interface, found that some data is not what we want, then the front-end should do or how to talk to the background?
  解决办法:1,首先要把请求的URL和返回的数据以及在页面的展示的情况给跟后台看,这样有理有据,后台开发人员是不会说什么的,佛则,后台会很不耐烦的,甚至骂你的可能都有,本身做后台比较难,尤其在查询数据,取数据,封装数据方面都比较难处理.
Summarize

Interacting with the background is basically the problem, and everyone should know something about it.
Blog Address: http://blog.csdn.net/baihuaxiu123

iOS front-end and background interaction technology implementation and technical details

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.