第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么button沒有觸發(fā)js函數(shù)?

為什么button沒有觸發(fā)js函數(shù)?

Will_木 2017-05-01 17:21:18
<script type="text/javascript">? ? ? ? ? ? var pathName = document.location.pathname;? ? ? ? ? ? var index = pathName.substr(1).indexOf("/");?? ? ? ? ? ?var app = pathName.substr(0, index + 1);? ? ? ? ? ? var xmlhttp;? ? ? ? ? ? function load(url, func) {? ? ? ? ? ? ? ? if (window.XMLHttpRequest) {? ? ? ? ? ? ? ? ? ? xmlhttp = new XMLHttpRequest();? ? ? ? ? ? ? ? } else {? ? ? ? ? ? ? ? ? ? xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? xmlhttp.onreadystatechange = func;? ? ? ? ? ? ? ? xmlhttp.open("GET", url, true);? ? ? ? ? ? ? ? xmlhttp.send();? ? ? ? ? ? }? ? ? ? ? ? function check(number) {? ? ? ? ? ? ? ? load(app + "/checknumber?guessnumber=" + number, function () {? ? ? ? ? ? ? ? ? ? if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {? ? ? ? ? ? ? ? ? ? ? ? checkingdiv = document.getElementById("checking");? ? ? ? ? ? ? ? ? ? ? ? checkingcontent = xmlhttp.responseText;? ? ? ? ? ? ? ? ? ? ? ? if (checkingcontent.trim().length === 0) {? ? ? ? ? ? ? ? ? ? ? ? ? ? checkingdiv.removeAttribute("style");? ? ? ? ? ? ? ? ? ? ? ? } else {? ? ? ? ? ? ? ? ? ? ? ? ? ? checkingdiv.setAttribute("style", "border: 1px dashed blue;");? ? ? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? ? ? ? ? checkingdiv.innerHTML = checkingcontent;? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? });? ? ? ? ? ? }? ? ? ? </script>調用部分:?<table>? ? ? ? ? ? <tr> ?? ? ? ? ? ? ? ? <td> <input type="text" name="number" /></td>? ? ? ? ? ? ? ? <td><input type="submit" value="猜" ?onclick="check(<%=request.getParameter("number")%>)"/></td>? ? ? ? ? ? ? ? <td><div id="checking"></div></td>? ? ? ? ? ? </tr>? ? ? ? </table>
查看完整描述

1 回答

?
風箏_0010

TA貢獻45條經驗 獲得超15個贊

這句有明顯的問題啊。。。。

?load(app?+?"/checknumber?guessnumber="?+?number,?function?()?{
????????????????????if?(xmlhttp.readyState?===?4?&&?xmlhttp.status?===?200)?{
????????????????????????checkingdiv?=?document.getElementById("checking");
????????????????????????checkingcontent?=?xmlhttp.responseText;
????????????????????????if?(checkingcontent.trim().length?===?0)?{
????????????????????????????checkingdiv.removeAttribute("style");
????????????????????????}?else?{
????????????????????????????checkingdiv.setAttribute("style",?"border:?1px?dashed?blue;");
????????????????????????}
????????????????????????checkingdiv.innerHTML?=?checkingcontent;
????????????????????}
}

你這個回調函數(shù)里面xmlhttp是哪里來的?我知道你是new的XHR對象,但是你傳參數(shù)的時候這個回調函數(shù)不知道啊,肯定會報錯吧。。。用this代替里面的xmlhttp

查看完整回答
反對 回復 2017-05-03
  • 1 回答
  • 0 關注
  • 1595 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號