I am pulling data from the server using the following service:

module.factory("annunciatorPanelsService", function ($http, $q) {
    return {
        getData : function(params){
            $http.defaults.withCredentials = true;
            var request = { id : 0, method : "someMethod", params : [] };
            var deferred = $q.defer();
            var response = $http({
                    method: "post",
                    crossDomain: true,
                    dataType:"xml",
                    withCredentials: true,
                    data: JSON.stringify(request),
                    headers: {
                        'Content-Type': "text/plain"
                    },
                    url: "http://.......
                });
            response.success(function (data) {
                deferred.resolve(data);
            });
            response.error(function (data) {
                alert('Error');
            });
            // Return the promise to the controller
            return deferred.promise;
        }
    }
});

It will not work at all if I dont specify headers as it is shown here. 
Another words, contentType: "text/plain" does not work. By not working I 
mean I would get 401.
The above code will get data back from the server, but Angular is 
choking then at the following line in angular.js:
* @param {string} json JSON string to deserialize.
 * @returns {Object|Array|Date|string|number} Deserialized thingy.
 */
function fromJson(json) {
  return isString(json)
      ? JSON.parse(json)
      : json;
}

And the error is:
SyntaxError: Unexpected token e
    at Object.parse (native)
    at fromJson 
(http://ajax.googleapis.com/ajax/libs/angularjs/1.2.9/angular.js:1036:14)

What are my options here?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to