天天看点

Stack overflow at line 错误总结

  栈溢出错误,原因,使用了js中保留关键字

  以后一定要注意

var xmlhttp;

  function onkeyup(){

   var keywd = document.getElementById('keywd').value;

   if(window.XMLHttpRequest){  //火狐

    xmlhttp = new XMLHttpRequest();

   }

   else if(window.ActiveXObject){

    xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');

   }

   var url ="test?keywd="+keywd;

   xmlhttp.open('post',url);

   xmlhttp.onreadystatechange = callback;

   xmlhttp.send(null);

  }

  function callback(){

   if(xmlhttp.readyState ==4){

    if(xmlhttp.status ==200){

     var str = xmlhttp.responseText;

     setDivForValue("myChild",str);

    }

   }

  }

  function setDivForValue(id,value){

   document.getElementById(id).innerHTML = value;

  }

第一个方法名onkeyup与键盘抬起事件重名,改一下这个名字就正常了