Take the 2-minute tour ×

I'm pretty new to Backbone and I've been trying to create autocomplete functionality with it, fed by an ASMX webservice. The issue I seem to have is whilst my webservice returns in JSON (after a painful battle with it), it wraps the response in a 'd' (dataset). How do I get the view to understand this and get at the correct data?

Here is my code:-

var Airline = Backbone.Model.extend({
                initialize: function () {},
                defaults: {
                    name: 'Airline Name',
                    rating: 50,
                    icon: '/blank.png'

            var AirlineCollection = Backbone.Collection.extend({
                model: Airline,
                contentType: "application/json",
                url: '/ControlTower/public/runway.asmx/all-airlines',
                parse: function (response) {
                    return response;

            var SelectionView = Backbone.View.extend({
              el : $('#airline'),
              render: function() {
                $(this.el).html("You Selected : " + this.model.get('AirlineName'));
                return this;

var airlines = new AirlineCollection();
            airlines.fetch({async: false, contentType: "application/json" });
            var airlineNames = airlines.pluck("AirlineName");

              source : airlineNames,
              minLength : 1,
              select: function(event, ui){
                var selectedModel = airlines.where({name: ui.item.value})[0];
                var view = new SelectionView({model: selectedModel});

Can anyone see what I'm doing wrong? I've been sitting here for too long now!

Help is appreciated ;)

share|improve this question

2 Answers 2

up vote 3 down vote accepted

What about in your AirlineCollection:

parse: function (response) {
  return response.d;
share|improve this answer
Doh! Just the ticket :) Many thanks. –  dooburt Aug 7 '12 at 20:46

This works for me

In AirlineCollection

parse: function (response) {
    return data;        
share|improve this answer

Your Answer


