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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

查找,保存正確的時(shí)候能顯示,錯(cuò)誤的時(shí)候P那就空白 求解

<!DOCTYPE?html>
<html>
<head>
????<meta?charset="UTF-8">
????<title>demojson</title>
</head>
<body>
????<h1>員工查詢</h1>
????<label>請(qǐng)輸入員工工號(hào)</label>
????<input?type="text"?id="keyWord"></br>
????<button?id="search">查詢</button>
????<p?id="searchResult"></p>
????<h1>員工保存</h1>
????<lable>請(qǐng)輸入員工姓名</lable>
????<input?type="text"?id="stuffName"></br>
????<lable>請(qǐng)輸入員工工號(hào)</lable>
????<input?type="text"?id="stuffNumber"></br>
????<label>請(qǐng)輸入員工職位</label>
????<input?type="text"?id="stuffJob"></br>
????<lable>請(qǐng)選擇員工性別</lable>
????<select?id="stuffSex">
????????<option>男</option>
????????<option>女</option>
????</select></br>
????<button?id="save">保存</button>
????<p?id="saveResult"></p>
<script>
????document.getElementById('search').onclick=function(){
????????var?request?=?new?XMLHttpRequest();
????????request.open("GET",?"serverjson.php?number="?+?document.getElementById("keyWord").value);
????????request.send();
????????request.onreadystatechange=function(){
????????????if(request.readyState===4){
????????????????if(request.status===200){
????????????????????var?data?=?JSON.parse(request.responseText);
????????????????????if(data.success){//判斷請(qǐng)求是否成功
????????????????????document.getElementById('searchResult').innerHTML?=?data.msg;
????????????????????}
????????????????}else{
????????????????????document.getElementById('searchResult').innerHTML?=?'錯(cuò)誤'+datamsg;
????????????????}
????????????}
????????}
????}
????????document.getElementById('save').onclick=function(){
????????var?request?=?new?XMLHttpRequest();
????????request.open('post','serverjson.php');
????????var?data='name='+document.getElementById('stuffName').value
?????????????????+?'&number='+document.getElementById('stuffNumber').value
?????????????????+?'&sex='+document.getElementById('stuffSex').value
?????????????????+?'&job='+document.getElementById('stuffJob').value
????????request.setRequestHeader('content-type','application/x-www-form-urlencoded');
????????request.send(data);
????????request.onreadystatechange=function(){
????????????if(request.readyState===4){
????????????????if(request.status===200){
????????????????????var?data?=?JSON.parse(request.responseText);
????????????????????if(data.success){
????????????????????document.getElementById('saveResult').innerHTML?=?data.msg;
????????????????????}
????????????????}else{
????????????????????document.getElementById('saveResult').innerHTML?=?'錯(cuò)誤'+?data.msg;
????????????????}
????????????}
????????}
????}
</script>
</body>
</html>


正在回答

2 回答

@天天4 ? 我覺(jué)得 ? 既然正確的能顯示 那么你應(yīng)該看看你的request.readyState 是否為4 ? ?而且40行代碼"'錯(cuò)誤'+datamsg;"? ??

0 回復(fù) 有任何疑惑可以回復(fù)我~

因?yàn)楦緵](méi)有錯(cuò)誤路徑可以走

<!DOCTYPE html>
<html>
<head>
??? <meta charset="UTF-8">
??? <title>demojson</title>
</head>
<body>
??? <h1>員工查詢</h1>
??? <label>請(qǐng)輸入員工工號(hào)</label>
??? <input type="text" id="keyWord"></br>
??? <button id="search">查詢</button>
??? <p id="searchResult"></p>
??? <h1>員工保存</h1>
??? <lable>請(qǐng)輸入員工姓名</lable>
??? <input type="text" id="stuffName"></br>
??? <lable>請(qǐng)輸入員工工號(hào)</lable>
??? <input type="text" id="stuffNumber"></br>
??? <label>請(qǐng)輸入員工職位</label>
??? <input type="text" id="stuffJob"></br>
??? <lable>請(qǐng)選擇員工性別</lable>
??? <select id="stuffSex">
??????? <option>男</option>
??????? <option>女</option>
??? </select></br>
??? <button id="save">保存</button>
??? <p id="saveResult"></p>
<script>
??? document.getElementById('search').onclick=function(){
??????? var request = new XMLHttpRequest();
??????? request.open("GET", "server.php?number=" + document.getElementById("keyWord").value);
??????? request.send();
??????? request.onreadystatechange=function(){
??????????? if(request.readyState===4){
??????????????? if(request.status===200){
??????????????????? var data = JSON.parse(request.responseText);
??????????????????? if(data.success){//判斷請(qǐng)求是否成功
??????????????????? document.getElementById('searchResult').innerHTML = data.msg;
??????????????????? }
??????????????? }else{
??????????????????? document.getElementById('searchResult').innerHTML = '錯(cuò)誤'+datamsg;
??????????????? }
??????????? }
??????? }
??? }
??????? document.getElementById('save').onclick=function(){
??????? var request = new XMLHttpRequest();
??????? request.open('post','server.php');
??????? var data='name='+document.getElementById('stuffName').value
???????????????? + '&number='+document.getElementById('stuffNumber').value
???????????????? + '&sex='+document.getElementById('stuffSex').value
???????????????? + '&job='+document.getElementById('stuffJob').value
??????? request.setRequestHeader('content-type','application/x-www-form-urlencoded');
??????? request.send(data);
??????? request.onreadystatechange=function(){
??????????? if(request.readyState===4){
??????????????? if(request.status===200){
??????????????????? var data = JSON.parse(request.responseText);
??????????????????? if(data.success){
??????????????????? document.getElementById('saveResult').innerHTML = data.msg;
??????????????????? }
??????????????? }else{
??????????????????? document.getElementById('saveResult').innerHTML = '錯(cuò)誤'+ data.msg;
??????????????? }
??????????? }else{
?? ??? ??? ??? ?alert(0);
?? ??? ??? ?}
??????? }
??? }
</script>
</body>
</html>


此時(shí):有個(gè)默認(rèn)的男

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
Ajax全接觸
  • 參與學(xué)習(xí)       224773    人
  • 解答問(wèn)題       708    個(gè)

本課程通過(guò)一個(gè)案例,講解Ajax的相關(guān)概念原理實(shí)現(xiàn)方式和應(yīng)用

進(jìn)入課程

查找,保存正確的時(shí)候能顯示,錯(cuò)誤的時(shí)候P那就空白 求解

我要回答 關(guān)注問(wèn)題
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)