Summary:
I'm looking to save the first 4kB of a webpage (actually an MP3, but shouldn't matter) from another domain to a variable in JavaScript, ideally without jQuery, as I don't need jQuery for anything else on my page. This is what I have used before in a python app previously to achieve the same goal:
host = 'http://www.wikipedia.org/somepath/tosome/file.mp3'
req = urllib2.Request(host, headers={'User-Agent' : "Magic Browser"})
response = urllib2.urlopen(req).read(4*1024)
.
Background:
I'm aiming to get just the few kilobytes of an MP3 file (from a different domain) so I can strip the ID3 info from it. However after a lot of googling, and messing around with xmlhttprequests, jsonp, and a few other things, I still cant find something that fulfills all of my requirements. Reading this post- Basic example of using .ajax() with JSONP? was really helpful but I cant seem to work out how to limit the callback size of something like that (perhaps limiting the scripts source size?) and I REALLY don't want to have to include the jQuery library.
Any help greatly is appreciated!