Я не могу получить строку ответа из метода выборки в методе рендеринга просмотра.Анализ синтаксического ответа
The Collection Class Goes here.
Collection = (function(){
var Events;
Events = Backbone.Collection.extend({
url:function(){
//alert(urlOptions);
return this.urlParam;
// alert('API call :'+urlOptions);
},
initialize: function(models, options){
this.urlParam = options.urlParam || "";
},
parse: function(response){
var parsed = Jath.parse(
[ '//notes', {
} ], response);
console.log(parsed);
return parsed;
}
});
return {
newInstance : function(models,options) { return new Events(models,options); }
};
})();
The View Goes Here
View = (function() {
'use strict';
var
htmlTemplate = _.template($('#eventGridTemplate').html()), // See templatesSearch.jsp
expanded = true, // By default the Events Grid extends to the bottom of the browser window.
BackboneView, applyStyles;
/**
* Apply CSS specific to this view
* Unfortunately, this View needs to modify its parent wrapper element.
* Otherwise the layout will break when it's resized. See templatesSearch.jsp.
* @param {Object} $elmt
* @param {Boolean} expand
*/
applyStyles = function($elmt, expand) {
var
top = '2px',
left = '2px',
pos = 'absolute',
right = '2px';
if (expand) {
$elmt.css({
"position" : pos,
"top" : top,
"left" : left,
"right" : right,
"bottom" : "2px"
});
$elmt.parent().css('bottom', '2px');
} else {
$elmt.css({
"position" : pos,
"top" : top,
"left" : left,
"right" : right,
"bottom" : "50%"
});
$elmt.parent().css('bottom', '50%');
}
};
// See 'http://backbonejs.org/#View-constructor' for more info
BackboneView = Backbone.View.extend({
onAiringsBtn : function(event) {
// If the Events Grid container was expanded, contract it.
// If it was contracted, expand it.
expanded = expanded ? false : true;
applyStyles(this.$('div'), expanded);
},
initialize : function() {
this.render();
},
render : function() {
// this.$el is the jQuery version of this.el
// Which is populated by options.el
// Which is part of the options object passed into the constructor
//alert('Start Date:' +$('#datepicker').datepicker('getDate'));
var eventsCollection = Collection.newInstance([],{urlParam:'http://localhost:8080/adtglobal/2.0/api/events?startDate=2013-11-05T00:00:00-0400&endDate=2013-11-06T00:00:00-0400'});
//console.log(eventsCollection.url());
eventsCollection.fetch({
success : function(eventsCollection , response){
console.log(eventsCollection.toJSON());
alert(eventsCollection.toJSON());
}
});
this.$el.html(htmlTemplate);
applyStyles(this.$('div'), true);
}
});
//-------------------------------------------------------------------------------------------------------------------
// Public API
//-------------------------------------------------------------------------------------------------------------------
return {
newInstance : function(options) { return new BackboneView(options); }
};
})();
Получаю ответ как успех, и я вижу xml в консоли браузера, но как его разобрать здесь?
Ответ здесь
<Events xmlns="urn:api:2.0">
<PageNavigation showing="45"></PageNavigation>
<Event id="400515625" href="400515625" source="SDR">
<OrgHierarchy>
<level id="56" typeId="100" title="Soccer" description="Sport" href="../sporthierarchy?levelId=56&levelTypeId=100"></level>
<level id="2902" typeId="101" title="UEFA" description="Confederation" href="../sporthierarchy?levelId=2902&levelTypeId=101" parentId="56" parentType="100"></level>
</OrgHierarchy>
<EventType id="1">Standard Event</EventType>
<League id="1860">UEFA > Polish Orange Ekstraklasa</League>
<EventTitleText>Ruch Chorzow vs. Zawisa Bydgoszcz</EventTitleText>
<CompetitionType id="1">Team vs Team</CompetitionType>
<EventCompetitors>
<Teams>
<HomeTeam id="73960" href="../teams/73960">Ruch Chorzow</HomeTeam>
<AwayTeam id="107278" href="../teams/107278">Zawisa Bydgoszcz</AwayTeam>
</Teams>
</EventCompetitors>
</Event>
</Events>
Какое значение «разбора» выглядит в вашей функции синтаксического анализа? –
Я не могу получить там никакой ценности. Ответ - это xml, который я могу видеть в консоли браузера, но не здесь. :-(Я очень новичок в позвоночнике, возможно, я, возможно, пропустил некоторые базовые вещи :-( – Vinay
вы можете разместить образец ответа на ваш сервер здесь? –