日期:2014-05-16 浏览次数:20428 次
<script language="javascript"> var xmlhttp; function ScoreTest(){ var strErr="" var iWrongs=0; for (var i=0;i<=20;i++){ if (parseInt(i)<10) x="0" else x=""; var e=document.getElementById("DLChinese_ctl"+ x + i +"_txtInput"); if (e==null) e=document.getElementById("DLChinese_txtInput_"+i); var h=document.getElementById("hd"+ i); if (e.value==h.value){ $$('spn'+h.value+'1').style.display='inline'; $$('spn'+h.value+'2').style.display='none'; $$('spn'+h.value+'3').style.display='none'; }else{ $$('spn'+h.value+'1').style.display='none'; $$('spn'+h.value+'2').style.display='none'; $$('spn'+h.value+'3').style.display='inline'; strErr=strErr+"|"+h.value; iWrongs=iWrongs+1; } } setTestResult("SaveTestRes.aspx?Unit=6&BookID=3&StepID=1&WrongList="+strErr); $$('hfWrongWords').value=strErr; alert('有'+iWrongs+'个单词拼写错误!'); if (iWrongs>0) $$('HidIWrongs').value=iWrongs; $$('BtnEndTest').style.display='none'; return false; } function setTestResult(strURL){ createXMLHTTPRequest(); xmlhttp.open("GET",encodeURI(strURL)); xmlhttp.onreadystatechange=HandleStateChange; xmlhttp.send(null); } function createXMLHTTPRequest(){ if (window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest(); }else if(window.ActiveXObject) xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); if (!xmlhttp) xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } function HandleStateChange(){ if(xmlhttp.readyState==4){ if (xmlhttp.status==200){ alert("拼写错误:" +xmlhttp.responseText); } } } </script> 调用 scoreTest时setTestResult 为什么没有执行呢?
function setTestResult(strURL) { createXMLHTTPRequest(); xmlhttp.open("GET", encodeURI(strURL)); xmlhttp.onreadystatechange = HandleStateChange; xmlhttp.send(null); alert('启动了AJAX')/////////// } function HandleStateChange() { if (xmlhttp.readyState == 4) { if (xmlhttp.status != 200) {////////应该是不等于200吧。。==200就是正常的了 alert("拼写错误:" + xmlhttp.responseText); } else alert('请求成功!') } }
------解决方案--------------------
用IE工具单步下看执行到哪里不执行