android - Backbone.js fetch goes to error when loading json file -


i'm trying load json file called internationalization.js, content of file:

{     "response": {         "loading": "loading",         "login.login": "log in"     } } 

this works fine on browser, when building ios or android app using cordova fetching fails , goes error function. i'm wondering if asynchronous nature of fetch works in different way when on mobile app. file found correctly xhr holds json content in responsetext, have seen when debugging in safari. code fetching:

var internationalizationmodel = new model({}, {url: config.internationalization}); internationalizationmodel.fetch({       success: _.bind(function(model){           window.polyglot = new polyglot({phrases: model.tojson()});           app.router.navigate("home",true);       }, this),       error: _.bind(function(model, xhr, options){           this.logout();       }, this) 

relevant methods in model:

      sync: function(method, model, options) {         var urlerror = function() {             throw new error('a "url" property or function must specified');         };         if (!options.url) {             options.url = _.result(model, 'url') || urlerror();         }         var params = {};         switch (method) {             case "create":                 params = this._create(model, options);                 break;             case "read":                 params = this._read(model, options);                 break;             case "update":                 params = this._update(model, options);                 break;             case "delete":                 params = this._delete(model, options);                 break;         }         return params;     }     _read: function(model, options) {         var params = _.extend({             headers: {accept: "*/*; charset=utf-8","content-type":"application/json"},             type: 'get',             datatype: 'json',             url: (options.params != undefined) ? options.url + options.params : options.url,             processdata: false,             crossdomain: true         }, options);          return $.ajax(params);      }     parse: function(res) {          if (res.response === undefined)             return res;          return res.response;     } 


Comments

Popular posts from this blog

cookies - Yii2 Advanced - Share session between frontend and mainsite (duplicate of frontend for www) -

angular - password and confirm password field validation angular2 reactive forms -

php - Permission denied. Laravel linux server -