function loadXMLDoc(url, val)
{
if ( xmlhttp ) {
if ( xmlhttp.readyState != 4 ) {
xmlhttp.abort();
}
xmlhttp = null;
}
if (window.XMLHttpRequest)
{// code for all new browsers
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{// code for IE5 and IE6
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlhttp!=null)
{
xmlhttp.onreadystatechange=state_Change;
xmlhttp.open("POST",url,true);
xmlhttp.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
console.log("just send");
xmlhttp.send( val);
}
else
{
alert("Your browser does not support XMLHTTP.");
}
}
function state_Change()
{
if (xmlhttp.readyState==4)
{// 4 = "loaded"
if (xmlhttp.status==200)
{// 200 = OK
// ...our code here...
alert(xmlhttp.responseText);
}
else
{
alert("Problem retrieving XML data " xmlhttp.status);
}
}
}
function sendHttpRequest()
{
console.log("send request");
var myArray = new ArrayBuffer(256);
var longInt8View = new Uint8Array(myArray);
for (var i=0; i< longInt8View.length; i++) {
longInt8View[i] = i % 255;
}
loadXMLDoc("http://192.168.1.102:8080/src/com/phei/netty/",longInt8View)
}
换成ajax的写法就正确了,遇到过类似问题的给解答下,谢了!
1 个回复
roblade (作者)
换成ajax的写法就正确了,遇到过类似问题的给解答下,谢了!