angularjs - IE SyntaxError: Expected '}' in JSON parsing from Java -


i have problem in 1 of projects.

we have backend in java , frondend app in html , angularjs (v1.4.6).

in frondend display table contaning records retrieved java in json format.

in java use gson convert object json format , send browser. here's java code:

public class dosomething {     public void caricafile(httpservletrequest request, httpservletresponse response, filtriparameters filtri) throws ioexception      {         retobj r = caricafile(request, response, filtri, ...);         response.getwriter().println(utils.json(r));     } }  public class utils {     public final static string json(object obj) {         return new gsonbuilder().serializenulls().create().tojson(obj);     } } 

here's our angular function

$scope.uploadfile = function(files) {     if (files.length == 0)         return;      openloader();     var fd = new formdata();     //take first selected file     fd.append("file", files[0]);      $http.post(urluploader, fd, {         withcredentials: true,         headers: {'content-type': undefined },         transformrequest: angular.identity     })     .success(function(response){         closeloader();         response = angular.fromjson(response);         //     })     .error(         function(response){             closeloader();             alert(response);         });      $( "#file-upload" ).val(""); } 

in chrome works fine, json received parsed , rows showed in html table.

in internet explorer following error. "response undefined" in error function

ie console:

syntaxerror: expected '}'    @ uc (http://127.0.0.1:8085/hermescs2/js/generics/1-4-6angular.min.js?vid=120:15:463)    @ zb (http://127.0.0.1:8085/hermescs2/js/generics/1-4-6angular.min.js?vid=120:82:227)    @ anonymous function (http://127.0.0.1:8085/hermescs2/js/generics/1-4-6angular.min.js?vid=120:83:141)    @ m (http://127.0.0.1:8085/hermescs2/js/generics/1-4-6angular.min.js?vid=120:7:320)    @ cd (http://127.0.0.1:8085/hermescs2/js/generics/1-4-6angular.min.js?vid=120:83:125)    @ d (http://127.0.0.1:8085/hermescs2/js/generics/1-4-6angular.min.js?vid=120:84:366)    @ anonymous function (http://127.0.0.1:8085/hermescs2/js/generics/1-4-6angular.min.js?vid=120:118:324)    @ n.prototype.$eval (http://127.0.0.1:8085/hermescs2/js/generics/1-4-6angular.min.js?vid=120:132:441)    @ n.prototype.$digest (http://127.0.0.1:8085/hermescs2/js/generics/1-4-6angular.min.js?vid=120:129:455)    @ n.prototype.$apply (http://127.0.0.1:8085/hermescs2/js/generics/1-4-6angular.min.js?vid=120:133:234) 

here pastebin json backend returns frontend/angular. https://pastebin.com/zuix3atv

we tested , it's valid json

any advice?

problem solved

i changed content-type in header response to: text/json somehow internet explorer affected whereas chrome/firefox no!

public class dosomething {     public void caricafile(httpservletrequest request, httpservletresponse response, filtriparameters filtri) throws ioexception      {         retobj r = caricafile(request, response, filtri, ...);         response.setcontenttype("text/json");         response.getwriter().println(utils.json(r));     } } 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -