weixin_33721344 2016-01-14 04:25 采纳率: 0%
浏览 184

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 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记