Note that there are some explanatory texts on larger screens.

plurals
  1. POCan I read binary data properly through XDomainRequest?
    primarykey
    data
    text
    <p>Edit: Taking dennmat's suggestion into consideration, I have managed to simplify my image acquiring script down to a few lines using <code>Image()</code>:</p> <pre><code>window.onload = function(){ var img; capture_canvas = document.createElement('canvas'); capture_canvas.width = 1000; capture_canvas.height = 1000; document.documentElement.appendChild(capture_canvas); img = new Image(); img.crossOrigin = "Anonymous"; img.src = "http://www.shangalulu.com/get_resource_no_64.php?url=http://www.shangalulu.com/users/1196739508/post/41-1330377498/41-1330377498_thumb.jpg"; img.onload = function() { var context, canvas_img; context = capture_canvas.getContext('2d'); context.drawImage(img, 0, 0, 255, 255); canvas_img = context.getImageData(0, 0, capture_canvas.width, capture_canvas.height); } } </code></pre> <p>While this works for Chrome and Firefox, this does not for IE9. The solution mentioned in the following link doesn't seem to apply to this situation. <a href="https://stackoverflow.com/questions/2704929/uncaught-error-security-err-dom-exception-18">Uncaught Error: SECURITY_ERR: DOM Exception 18 when I try to set a cookie</a></p> <p>Is the cors feature in <code>Image()</code> supported by IE9?</p> <hr> <p>I've run into a wee little problem.</p> <p><a href="http://www.shangalulu.com/get_resource_no_64.php?url=http://www.shangalulu.com/resources/images/sample/sample.png" rel="nofollow noreferrer">http://www.shangalulu.com/get_resource_no_64.php?url=http://www.shangalulu.com/resources/images/sample/sample.png</a></p> <p>The above image is actually a file that contains the standard png header, followed by 255 bytes going from 255 down to 0 (twice). The idea was to see how Internet Explorer 9 handled receiving binary data through an AJAX request.</p> <p>So, here's my problem: I've noticed that when I receive a byte on the client that's greater than 127, the value is defaulted to 253. Is there a way to get IE to read the extended bytes with the correct values?</p> <p>A few things to take note of:</p> <p>1) We do not use any sort of javascript framework. It is a requirement that we do this only with bare bones javascript.</p> <p>2) The intent of this experiment is to make a clean way to get an image so I can place it on a canvas without tainting it. Sometimes these images come from our externally hosted image server, other times it will come from another host that we have no control over.</p> <p>Attached below is my testing script:</p> <pre><code>var request; window.onload = function(){ request = new XMLHttpRequest(); if (window.XDomainRequest) { request = new XDomainRequest(); } request.open('GET', "http://www.shangalulu.com/get_resource_no_64.php?url= http://www.shangalulu.com/resources/images/sample/sample.png", true); request.onload = function() { var binary, i, response; response = this.responseText; binary = ""; if (this.contentType) { document.documentElement.appendChild( document.createTextNode(this.contentType)); document.documentElement.appendChild(document.createElement('br')); } for( i=0; i &lt; response.length; i++) { binary = "Line " + (i) + " --&gt; " + ((response.charCodeAt(i)) &amp; 0xff); document.documentElement.appendChild(document.createTextNode(binary)); document.documentElement.appendChild(document.createElement('br')); } }; request.send(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload