0

In my application we use Restangular and $http to communicate with server API.

First request (the one /BasicInfo.json on the picture) is done using Restangular for retrieving initial information, like user name, and also Number pointer to part of the of the app is used (appId). Other requests use this data for further calls, they are done just with using regular $http service.

But in IE9 specifically (not >=IE10, I also have html5shiv) I get the resolved response as a string of chars, like this:

[123,23,45,98,143,...]

That is why first piece of data is not processed properly and other calls cannot resolve - see "undefined" in the URL in the picture. Second and subsequent call use following patters for forming the URL.

//baseURL and docId - are available, while appId is not
$http.get(baseURL + '/api/' + appId + '/Subjects/' + docId + '.json')
.success(function(data){ deferred.resolve(data);
..

requests in the app

This line is actually a list of Chars containing correct server response, but in such a weird way. I've found the way to convert it using function like this:

//numbersLine is that actual line [123,23,45,98,143,...] 
  var str = '',
  convertedArray = Array(numbersLine)[0];

for (var i = 0; i < convertedArray.length; i++) {
    str = str + String.fromCharCode(convertedArray[i]);
}

return str;

But I have to do this conversion everywhere in the app where I deal with API data, because of this IE9 strange behaviour. Any advice about what I could check/change would be very appreciated.

[UPD]

This is module setup

define([
    'angular',
    './modulename',
    'app/base/base-module',
//module definition via RequireJS

angular.module('app.modulename').config(
        ['$stateProvider', '$BasicProvider', 
            function ($stateProvider, $BasicProvider) {

        $stateProvider.state('***', {
                    url: '***',
                    views : {
                        ///
                    },
                    resolve : {
                        //here should get POJO with appid
                        resolvedBasicInfo : ["$Basic", function($Basic){
                            return $Basic.getBasicInfo();
                        }],
//later goest two other calls that require this appid 

And Base module itself has Restangular call

define([
    'angular',
    'restangular',
    //other configs

], function( angular, Restangular ) {

    'use strict';

    return angular.module('effactsApp.base').provider('$Basic', function(){

        return {
            $get : ['Restangular', 'baseApiService', //other configs
                function (Restangular, baseApiService) {
//

                    if(!basicInfoRestCall){
                        basicInfoRestCall = Restangular.one('BasicInfo');
                    }

@dhavalcengg, hope it gives the idea

shershen
  • 9,875
  • 11
  • 39
  • 60
  • Can you post some code, when your are setting appid for your application? Also response you are getting when sending request for that. – dhavalcengg Jan 31 '15 at 10:53

2 Answers2

0

Have you tried to set the header for the response in the $http header to Content-type: application/json; charset=utf-8?

documentation for $http

Rinrub
  • 137
  • 10
  • $http is done via Restangular and $http services; setup is correct since it works in *all* other browsers, IE11 and IE10 as well – shershen Feb 02 '15 at 20:49
0

Occasionally I've found the issue that directly happened in my case: https://github.com/mozilla/pdf.js/issues/5429

This is exactly conditions I had:

  • PDF.js + compatibility.js
  • AngularJS + Router + AJAX calls
  • IE9

Which leaded to XHR request to load data in incorrect way.

shershen
  • 9,875
  • 11
  • 39
  • 60