How to parse binary data

19 views
Skip to first unread message

Amms

unread,
Nov 14, 2018, 5:54:10 AM11/14/18
to backbonejs
Hello,


       I need to display jpeg image after retrieved from my server.

   With XMLHttpRequest its working:
  
         var xhr = new XMLHttpRequest();
         xhr.open('GET', value, true);
         xhr.responseType = 'arraybuffer';
          xhr.onload = function (e) {
                        var arrayBufferView = new Uint8Array( this.response );
                        var blob = new Blob( [ arrayBufferView ], { type: "image/jpeg" } );
                        var urlCreator = window.URL || window.webkitURL;
                        localSrc = urlCreator.createObjectURL( blob );
                        var img = new Image();
                        img.src=localSrc;
                        $('#jpg'+i).append(img);
           };
            xhr.send();


How can we perform the same in backbonejs ? Is it possible with model.fetch() method ?If yes , how?


Thanks in advance and any help is appreciable.
Reply all
Reply to author
Forward
0 new messages