3

Can this code be converted to jQuery code? For example by using: jQuery.get(). Although I don't think there is an responsetype arraybuffer.

var request = new XMLHttpRequest();
request.open("GET", url, true);
request.responseType = "arraybuffer";
request.onload = function() {
  // do stuff
}

request.send();

EDIT

I'm trying to make a Chrome HTML5 Web Audio plugin for jQuery. So I'm trying to jQuerify where possible. Check out what I try to convert @ http://pieterhordijk.com/sandbox/html5-audio-api/webkit-audiocontext-interface/adding-a-basic-control

Word of caution don't click the play button with the volume high as you can only stop it for now with a refresh of the page :)

7
  • Your onload should read onreadystatechange. responseType is only supported from FF >= 6. Commented May 21, 2011 at 18:34
  • @Marcel: What is FF? And Why would I change onload to onreadystatechange? Commented May 21, 2011 at 18:40
  • FF = Firefox; onload is not a property of XMLHttpRequest objects. Commented May 21, 2011 at 18:46
  • Well the stuff I'm working on is experimental (Chrome canary build). So you might be right about the browser support. And I need to use onload in stead of onreadystatechange. Commented May 21, 2011 at 18:49
  • Aha, that makes things more clear. But why do you need to use onload? Commented May 21, 2011 at 18:51

1 Answer 1

1
$.get(url, function (data) {
    // do useful things with data
});

Adjust parameters as you like, see jQuery.get().

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.