I am new to the world of backbone.js . I want to communicate with the server using backbone.js and render the employee details on to the table .I am getting the data from the server using following code:

2 Answers
2

Let us assume you have a table in your HTML page with id="employee" and you have defined a template corresponding to a row in the table. For simplicity, we asssume employee row just has firstname and lastname:

After you fetch the collection from the server, the items are stored within the collection. You can view the retrieved data using the following code. On success we create a new employee list (table in this case) and pass the employee collection.

First of all, you can get much more information if you use console.log in this way console.log('response inside parse', res);. res won't be converted to string, but it will be displayed as a JavaScript object with all its properties and values. Then, check the backbone.js docs Collection.parse and read what the res is in this context and what this method should return.

Probably next step would be to create a View which renders a table using some template and data from your collection.