Thursday, 19 September 2013

fetch data from a url in javascript

fetch data from a url in javascript

I am trying to fetch a data file from a URL given by the user, but I don't
know how to do. Actually, I can get data from my server successfully. Here
is my code:
$("button#btn-demo").click(function() {
$.get('/file', {
'filename' : 'vase.rti',
},
function(json) {
var data = window.atob(json);
// load HSH raw file
floatPixels = loadHSH(data);
render();
});
});
It can fetch the binary data from my server, parse the file and render it
into an image. But now I want it work without any server, which means
users can give a URL and javascript can get the file and render it. I know
it's about the cross-site request. Can you tell me about it and how to
realize it? Thanks in advance!

No comments:

Post a Comment