Guided Tour: QBO3 and BackboneJS

Configuring CORS Headers

qbo.fetch = function(){
  $.ajax({
        type: 'POST',
        url: qbo.url,
        crossDomain: false,
        username: "ChangeToYourEmail@company.com",
        password: "ChangeToYourPassword",
        headers: {
            'qboAutomation': true
        },
        xhrFields: {
            withCredentials: true
        }
    }).success(qbo.success);
};

Logging In

var QBO = Backbone.Model.extend({});
var qbo = new QBO();
qbo.url = "http://demo.quandis.net/Security/Person.ashx/Select?ID=1&Output=Json";

qbo.success = function(json){
  qbo.set({data: json});
  qboView.render();
};

qbo.fetch = function(){
  $.ajax({
        type: 'POST',
        url: qbo.url,
        crossDomain: false,
        username: "ChangeToYourEmail@company.com",
        password: "ChangeToYourPassword",
        headers: {
            'qboAutomation': true
        },
        xhrFields: {
            withCredentials: true
        }
    }).success(qbo.success);
};

qbo.fetch();

var QBOView = Backbone.View.extend({
  render: function(){
    var data = JSON.stringify(this.model.get('data'), undefined, 2);
    var html = '<div>' + data + '</div>';
    $('#test').html(html);
  }
});
var qboView = new QBOView({model: qbo});

Comments