i have a code like below
then, i call that function by using this below html buttonCode:function get_image(image_path){ document.querySelector('#status').innerHTML = 'loading..'; //tambahkan loading text window.URL = window.URL || window.webkitURL; // Take care of vendor prefixes. var xhr = new XMLHttpRequest(); xhr.open('GET', image_path, true); xhr.responseType = 'blob'; //respondnya blob xhr.onload = function(e) { if (this.status == 200) { var blob = this.response; var img = document.createElement('img'); img.onload = function(e) { window.URL.revokeObjectURL(img.src); // Clean up after yourself. }; img.src = window.URL.createObjectURL(blob); document.body.appendChild(img); document.querySelector('#status').innerHTML = ''; //hilangkan loading text } }; xhr.send(); }
Unfortunatey Chrome and Firefox 10 return origin null,Code:<input type="button" value="Get image" onclick="get_image('http://mysite.com/Screenshot_html5_form.gif');"/><br/> <span id="status"></span>
i see chrome says like this -> XMLHttpRequest cannot load http://mysite.com/Screenshot_html5_form.gif. Origin null is not allowed by Access-Control-Allow-Origin.
So, what should i do????



Reply With Quote
Bookmarks