Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9324403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T04:35:20+00:00 2026-06-19T04:35:20+00:00

I’m building a web app with Django on back-end and Backbone.js on front-end I

  • 0

I’m building a web app with Django on back-end and Backbone.js on front-end

I have problems with IE when I’m trying to fetch data from the server. When I run my HTML page in IE, the collection fetch always invoke the error func.

My code:

$(function(){

var Chapter = Backbone.Model.extend({});

var Chapters = Backbone.Collection.extend({
    model: Chapter,
    url: 'http://ip.olya.ivanovss.info/chapters'
});

var chapters = new Chapters();

var Router = new (Backbone.Router.extend({
    routes: {
        "": "choose_activity",
        "/": "choose_activity"
    },

    choose_activity: function () {
        chapters.fetch({
            success: function () {
                AppView.render();
            },
            error: function() {
                alert('error');
            }
        });
    }
}))();

var AppView = new (Backbone.View.extend({
    el: '.popup',
    templates: {
        choose_activity: Handlebars.compile($('#tpl-activities').html())
    },
    render: function () {
        this.$el.html(this.templates["choose_activity"]({ chapters: chapters.toJSON()}));
    }
}))();

Backbone.history.start();
});

Django’s View:

def chapters(request):
    chapters = list(Chapter.objects.order_by('id'))
    response = HttpResponse(json.dumps(chapters, default=encode_myway), mimetype='text/plain')
    if request.META.get('HTTP_ORIGIN', None) in ('http://localhost', 'http://html.olya.ivanovss.info', 'http://10.0.2.2'):
        response['Access-Control-Allow-Origin'] = request.META['HTTP_ORIGIN']
    return response

Thank you in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T04:35:22+00:00Added an answer on June 19, 2026 at 4:35 am

    IE7 doesn’t support CORS.

    There are 2 ways around this. The EASY way is Proxy over your API. My Python is rusty (I’m a Node/PHP dev), but I’m sure that there are a million and one resources on how do do this. The good thing about this is you don’t have to touch the API. But it means your local server has to CURL and return every single request from your API server.

    And second (and much less server intensive way) is JSONP! The idea of JSONP is that it appends a <script> to the document with the URL you specify. jQuery appends a ?callback=jQueryNNN where NNN is a random number. So effectively when the <script> loads, it calls jQueryNNN('The Response Text') and jQuery knows to parse the response from there. The bad thing about this is you have to wrap all of your responses on the API side (which is super easy if you’re just starting, not so easy if you already have an infrastructure built out).

    The annoying things about JSONP is that by it’s nature you can’t do a POST/PUT/DELETE. BUT you can emulate it if you have access to the API:

    Backbone.emulateHTTP = true;
    
    model.save();  // POST to "/collection/id", with "_method=PUT" + header.
    

    To integrate JSONP with Backbone is pretty simple (little secret Backbone.sync uses jQuery’s $.ajax() and the options parameters forwards over to jQuery ;)).

    For each one of your models/collections which access a cross origin you can add a su

    var jsonpSync = function (method, model, options) {
        options.timeout = 10000; // for 404 responses
        options.dataType = "jsonp";
        return Backbone.sync(method, model, options);
    };
    

    In each collection and model what does cross-origin:

    var MyCollection = Backbone.Collection.extend({
        sync  : jsonpSync
    });
    

    Or just overwrite the whole Backbone sync

    Backbone.__sync = Backbone.sync;
    
    var jsonpSync = function (method, model, options) {
        options.timeout = 10000; // for 404 responses
        options.dataType = "jsonp";
        return Backbone.__sync(method, model, options);
    };
    
    Backbone.sync = jsonpSync;
    

    On the server side you can do: this to return a JSONP response (copy pasted here):

    def randomTest(request):
        callback = request.GET.get('callback', '')
        req = {}
        req ['title'] = 'This is a constant result.'
        response = json.dumps(req)
        response = callback + '(' + response + ');'
        return HttpResponse(response, mimetype="application/json")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to loop through a bunch of documents I have to put
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am currently running into a problem where an element is coming back from
I am using jsonparser to parse data and images obtained from json response. When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.