search

Home  >  Q&A  >  body text

node.js - 为什么要用Node,AJAX就可以访问后台APIS接口了?

 **现在的项目中用的是Express+Jquery,如果页面需要请求数据,就通过$.ajax()(jquery的异步方法)请求,被express router 匹配到的 controller 处理后,再通过$http 调用后台接口请求后台数据。这种通过node中间层 和 直接 使用$ajax 有什么区别?**
PHP中文网PHP中文网2873 days ago430

reply all(2)I'll reply

  • 怪我咯

    怪我咯2017-04-17 15:47:21

    Maybe it’s for cross-domain

    reply
    0
  • 黄舟

    黄舟2017-04-17 15:47:21

    The node middle layer can be regarded as an interceptor. It will send your request to Sister Lan, do some processing, and then forward it to the background. It may be used to deal with security issues, or when exposing an interface to the outside world.

    What you said downstairs is right, it is also possible to choose node middleware as a third-party server for cross-domain cross-domain purposes

    reply
    0
  • Cancelreply