I am using backbonejs in my sample appliction. previously, I was hosting this on nodejs but now want to run it on tomcat but this change is giving me an error on the client browser. I search and found that to solve this issue crossdomain (https://stackoverflow.com/a/33820700/5086633) has to be set to true. Not sure how and were should I handle this. Any help in this regard is highly appreciated.
XMLHttpRequest cannot load http://localhost:8080/backbonejs/testpost.
Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'null' is therefore not allowed access. The response
had HTTP status code 403.
Using ajaxPrefilter, model and collection as below.
$.ajaxPrefilter( function( options, originalOptions, jqXHR ) {
options.url = 'http://localhost:8080/backbonejs' + options.url;
});
var Banks = Backbone.Collection.extend({
url: '/testpost'
});
var Bank = Backbone.Model.extend({
urlRoot: '/testpost'
});