akutqq
Last Updated: February 25, 2016
·
1.887K
· antillas21

Backbone and CORS

When building a Backbone-based JS app, if you need to connect to a third-party API with CORS support, don't forget to adjust jQuery's ajaxSetup to use XMLHttpRequest:

$.ajaxSetup({
    headers: { 'X-Requested-With' : 'XMLHttpRequest' }
});

This will save you some headaches when making requests to the API.