weixin_33721344 2016-01-13 20:25 采纳率: 0%
浏览 185

IE8中的POST二进制数据

I am trying to POST raw data of 512 bytes to an Arduino with an Ethernet shield from Internet Explorer 8. If you don't already know, an Arduino is a very small microcontroller with a VERY limited amount of RAM (SRAM), therefore neither Base64 nor URL encoding the data is an option or the stack will overflow.

I need to send this data very quickly in very short intervals (somewhere between 100ms and 250ms). No more, no less than 512 bytes of raw, un-encoded, unprocessed, binary data from IE8 (IE8 because IE9+ is not available for Windows XP) inside one POST request body.

This code works in FireFox

function PostDMXData(evt)
{
    var buff=new ArrayBuffer(512);
    var bytesArray=new Uint8Array(buff);
    for(var i=0;i<512;i++)
    {
        bytesArray[i]=DMXData[i];
    }
    jQuery.ajax({
       url: "dmxdata.php",
       type: "POST",
       async: true,
       error: function(a,b,c){alert(c);},
       complete: function(a,b)
       {
        if(evt){evt();}
       },
       contentType: "application/octet-stream",  
       data: bytesArray,
       processData: false
    });
    delete buff;
    delete bytesArray;
}

But not in IE8. alert(c) inside the error function displays "Error: The parameter is incorrect." Using a non-minimized jQuery I found that it's an exception being generated by the XMLHttpRequest object on .send(...) itself.

I've tried using 2 different polyfills/shims for the Uint8Array data type that I found referenced here on StackOverflow for a number of related questions but it seems none of these are compatible.

Should I continue looking for another Uint8Array shim, give up on Ajax, or should I try something else with Ajax/jQuery?

展开全部

  • 写回答

0条回答 默认 最新

      编辑
      预览

      报告相同问题?

      悬赏问题

      • ¥15 PADS Logic 原理图
      • ¥15 PADS Logic 图标
      • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
      • ¥20 气象站点数据求取中~
      • ¥15 如何获取APP内弹出的网址链接
      • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
      手机看
      程序员都在用的中文IT技术交流社区

      程序员都在用的中文IT技术交流社区

      专业的中文 IT 技术社区,与千万技术人共成长

      专业的中文 IT 技术社区,与千万技术人共成长

      关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

      关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

      客服 返回
      顶部