I am using web service call in a Backbone.js script to get the collection objects response in console using following code:
<script>
$(document).ready(function(){
var pgServerName =$("#serverName").text();
var pgPort =$("#serverPort").text();
var pgProjectName =$("#projectName").text();
var userLogged =$("#loggedInUser").text();
$("button").on('click', function(){
Server=Backbone.Model.extend({});
ServerList= Backbone.Collection.extend(
{
model:Server,
url:"/MicroStrategy/servlet/taskProc?taskId=getAllUserDecks&taskEnv=xhr&taskContentType=json&iServer="+pgServerName+"&port="+pgPort+"&userId="+userLogged+"&authMode=64&projName="+pgProjectName,
initialize:function(){
alert('In collection init');
}
}
);
list=new ServerList;
list.fetch({
success:function(collection, response)
{
alert(response);
console.log(response);
},
error:function(){alert("error");}
});
});
});
I got the following response in my console:
"deckIds": Array[3] [
0 Object {
"port": "30170",
"deckName": "Interactive Sandbox",
"projName": "CFO Sandbox",
"createdDateTime": "3/5/2015 11:39:36 AM",
"deckId": "12",
},
Object 1 {
"port": "30170",
"deckName": "Standard Management Reporting",
"projName": "Standard Management Reporting",
"createdDateTime": "2/18/2015 8:15:14 AM",
"deckId": "1",
},
Object 2{
"port": "30170",
"deckName": "Month End Tracking Reports",
"projName": "Standard Management Reporting",
"createdDateTime": "2/12/2015 7:24:01 AM",
"deckId": "3",
},
Now I want to display the deckId, createdDateTime, deckName in html format in the below code:
<table id="example">
<thead>
<tr>
<th>deckId</th>
<th>deckName</th>
<th>createdDateTime</th>
</tr>
</thead>
<tbody>
<tr>
<td>actual data from deckId</td>
<td>actual data from deckName</td>
<td>actual data from createdDateTime </td>
</tr>
</tbody>
</table>
How do I display the response I got in console on html page ? Please help.