Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am building an online social network. I have finished writing RESTful API service using Django. This will return only JSON response (No HTML will be generated from server side) so that this JSON response can be used to build native smartphone apps. API service being common to all clients.

My question is, since there is no HTML response from server side, can the MV* Javascript Frameworks like Angular / Backbone / Ember take care of complete Front-end, right from generating HTML page with CSS?

share|improve this question
1  
If you want HTML returned why can't you just wrap it into JSON? Or maybe you decided for the wrong tool for the task? –  JensG Nov 20 '13 at 11:50
    
can the MV* Javascript Frameworks like Angular / Backbone / Ember take care of complete Front-end? Yes they can. Call you web serive APIs using AJAX and use the returned JSON to create UI (using HTML, JS/ CSS). –  Aziz Shaikh Nov 20 '13 at 13:05
    
@JensG I have planned to use the same API service for building native Smartphone apps and so I do not want HTML content with response. I just want values as JSON data and use the data in html (if web) or use the data on phone apps to present it to user. –  Prashere Nov 20 '13 at 14:15
    
Reasonable, and the better approach. You should edit that into the question, IMHO. –  JensG Nov 20 '13 at 14:30
    
Done, I have edited the question as you suggested JensG. @AzizShaikh my concern is Social network cannot be a single page apps, but MV* JS frameworks are exceptional in doing Single Page Apps, Can they handle these things too? –  Prashere Nov 20 '13 at 16:11
show 1 more comment

2 Answers

up vote 0 down vote accepted

Yes definitely a MV* framework will work for you.

I am already working on a project where we use Zend framework's REST API which throws only JSON data and BackboneJS on the client side for generating and rendering the HTML content.

BackboneJS I would suggest. Alternatively AngularJS would be a very good option as it allows dynamic binding and easy MODEL - VIEW and VIEW - MODEL binding i.e. binding in AngularJS is both ways.

share|improve this answer
add comment

Yes to any of the MV* frameworks. All of them were designed to work with a REST API. Those frameworks will take the JSON data returned from the REST service, store it in memory on the client, and also use that data to generate the HTML.

A good sample app for using a Rest API with Backbone/Angular a couple of friends and I put together can be found up on Github. It doesn't do a whole lot, but it should be a good place to start. The App is written in ASP.NET MVC, but all the UI (specifically the angular section) is straight HTML/CSS. You can easily pull that piece out into a seperate project and everything would still work.

https://github.com/itsjason/OrderTracker

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.