javascript - Backbone Routing, CORS issue -
javascript - Backbone Routing, CORS issue -
i trying create single page app using backbone.js on clicking 'home' tab should load page associated model div#content1. code works fine page in local folder lets if want load external page, 'https://www.google.com' instance, error "cross-origin request blocked: same origin policy disallows reading remote resource @ https://www.google.com/. can fixed moving resource same domain or enabling cors." how around issue or how can otherwise link external urls backbone routers?
<!doctype html> <html><head> <title>demo</title> <script src="jquery-2.0.3.min.js" type="text/javascript" ></script> <script src="underscore-min.js" type="text/javascript" ></script> <script src="backbone-min.js" type="text/javascript" ></script> <script type="text/javascript"> $(function($) { var modelhome = new backbone.model({name: 'home', page: 'https://www.google.com'}); var router = backbone.router.extend({ routes: { "home": "homeclick" }, homeclick: function() { new expandableview({model: modelhome, el: $('#mainbox')}).render(); } }); var expandableview = backbone.view.extend({ render: function() { this.$el.load(this.model.get('page')); homecoming this; } }); var route = new router(); backbone.history.start({ pushstate: false }); }); </script> </head> <body> <div class="container" > <nav style="width:100%" role="navigation" > <ul> <li><a href="#home">home</a></li> </ul> </nav> <div id="mainbox" style="position:absolute; top:20%; left:10%; width:50%; height:100%; overflow:hidden;border:2px solid #000000;" > </div> </div> </body> </html>
javascript backbone.js cors backbone-routing
Comments
Post a Comment