将Javascript的XMLHttpRequest转换为jQuery

3

这段代码能否转换为 jQuery 代码?例如,使用:jQuery.get()。虽然我不认为有 responsetype arraybuffer

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

request.send();

编辑

我正在尝试为jQuery制作Chrome HTML5 Web Audio插件。因此,我正在尽可能地使用jQuerify。查看我尝试转换的内容@ http://pieterhordijk.com/sandbox/html5-audio-api/webkit-audiocontext-interface/adding-a-basic-control

警告:不要在音量高的情况下单击播放按钮,因为现在只能通过刷新页面来停止它 :)


你的 onload 应该改为 onreadystatechangeresponseType 仅在 FF >= 6 中支持。 - Marcel Korpel
@Marcel:FF是什么?为什么我要将onload更改为onreadystatechange? - PeeHaa
FF代表火狐浏览器;‘onload’不是XMLHttpRequest对象的属性。 - Marcel Korpel
啊哈,这样就更清楚了。但是为什么你需要使用 onload - Marcel Korpel
我无法测试这个,我的Chromium版本不够新。 - Marcel Korpel
显示剩余2条评论
1个回答

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

按您自己的喜好调整参数,查看jQuery.get()


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接