search

Home  >  Q&A  >  body text

javascript - 前端和后台数据交互有哪些方法?之间的联系?具体细节?

我是个前端,现在刚接触数据交互的这方面知识,知道可以解析json数据,可以写php接受后台数据,然后动态生成页面,知道的仅限这些了,还想知道更多的数据交互的东西
求大神们前来指点,发表意见和具体细节介绍!!
跪求!!!跪求!!!跪求!!!

PHPzPHPz2738 days ago608

reply all(3)I'll reply

  • 漂亮男人

    漂亮男人2017-05-16 13:02:02

    The front-end and back-end data interaction relies on HTTP (or other derived types, such as SSE, WS, etc.)

    What methods are available on the front end to initiate HTTP requests?

    Orthodox Network API

    XMLHttpRequest

    Orthodox XHR request, with same-origin restriction

    EventSource

    It is SSE (server push) technology, evolved from HTTP

    WebSocket

    Bi-directional long connection communication between client and server

    navigator.sendBeacon

    The new asynchronous data reporting API is specially used for data collection. The browser will only perform data reporting at the appropriate time.
    A typical scenario is to collect and report outbound behavior in a non-blocking manner.

    Some black magic

    <img>

    In the past, when we did data collection and reporting, such as PV collection, we often used the img tag to construct a harmless HTTP GET request and pass the data to the backend through querystring.
    For example, the commonly used GA should now be used insteadsendBeacon, but img should be retained as a low version compatibility solution

    <script>

    The famous JSONP uses the script tag to obtain data from the backend across domains

    More

    Let’s think about it. Can we use <link><iframe> to interact with data?

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-16 13:02:02

    This should help you
    http://www.cnblogs.com/cxying...

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 13:02:02

    Three modes of front-end and back-end division of labor:
    http://www.algorithmdog.com/%...

    reply
    0
  • Cancelreply