Domanda

Lets say I want to implement an API from an external website, for example like Dribbble or Last.fm.

I'm fairly new to this new generation of front-end MVC's (angular, etc), and most example's I've seen implement API's in the front-end with use of ajax calls.

So my question is this, is there a benefit of doing this, instead of lets say calling the API requried in the back-end(php)? What are some obvious drawbacks/benefits from each approach?

È stato utile?

Soluzione

Interactivity.

Putting functionality in the browser has the same advantages that putting functionality in any other user interface does, as opposed to just showing static forms: you get to interact with the user in real-time, instead of waiting for the user to fill out the form, submit it to the server, and wait for a full-page response.

Some examples of this:

  1. Validating fields as the user types them.
  2. Providing real-time display and updates of dashboard data, widgets or graphs.
  3. Providing real-time control of and access to server functionality.
  4. Allowing for other modes of interaction, such as machine to machine.

And so on.

Imagine a first-person shooter game that didn't have these facilities, that relied on a postback of the entire page for anything to happen. Wouldn't be very interesting or nimble, would it?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
scroll top