Exchanging binary data in the absence of ArrayBuffer

You want to use jQuery to send binary data using jQuery.get() or jQuery.post(), and discover that it cannot send binary data without a patch. You use the patch and discover that your JavaScript implementation does not support ArrayBuffer for some strange reason.

Well then, here’s a hack that can work for small amounts of binary data, use an Array of numbers. For instance:

    var buf = new Array(10);
    buf[0] = 0;
    buf[1] = 1;
    buf[2] = 2;
    buf[3] = 3;
    buf[4] = 4;
    $.post(url, {buffer: buf});

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s