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

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

關(guān)于員工創(chuàng)建的問題

我的代碼感覺沒有問題,為什么在創(chuàng)建員工的時候老是參數(shù)錯誤

http://img1.sycdn.imooc.com//57ec88b90001fb8b10050726.jpg


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Demo</title>
<style>
*{ font-size:30px; line-height:1.8}
</style>
</head>

<body>
<h1>員工查詢</h1>
<label>請輸入員工編號:</label>
<input type="text" id="keyword">
<button id="search">查詢</button>
<p id="searchResult"></p>

<h1>員工創(chuàng)建</h1>
<label>請輸入員工姓名:</label>
<input type="text" id="staffName"><br/>
<label>請輸入員工編號:</label>
<input type="text" id="staffNumber"><br/>
<label>請選擇員工姓名:</label>
<select id="staffSex">
<option>男</option>
<option>女</option>
</select><br/>
<label>請輸入員工職位:</label>
<input type="text" id="staffJob"><br/>
<button id="save">保存</button>
<p id="createResult"></p>
<script>
document.getElementById("search").onclick = function(){
?? ?//發(fā)送Ajax查詢請求并處理
?? ?var request = new XMLHttpRequest();
?? ?request.open("GET","service.php?number=" + document.getElementById("keyword").value);
?? ?request.send();
?? ?request.onreadystatechange = function(){
?? ??? ?if(request.readyState === 4){
?? ??? ??? ?if(request.status === 200){
?? ??? ??? ??? ?document.getElementById("searchResult").innerHTML = request.responseText;
?? ??? ??? ?}else{
?? ??? ??? ??? ?alert("發(fā)生錯誤:" +request.status);
?? ??? ??? ?}
?? ??? ?}
?? ?}
}

document.getElementById("save").onclick = function(){
?? ?//發(fā)送Ajax查詢請求并處理
?? ?var request = new XMLHttpRequest();
?? ?request.open("POST","service.php");
?? ?var data = "name=" + document.getElementById("staffName").value
?? ??? ??? ??? ?+ "&number=" + document.getElementById("staffNumber").value
?? ??? ??? ??? ?+ "&sex=" + document.getElementById("staffSex").value
?? ??? ??? ??? ?+ "&job=" + document.getElementById("staffJob").value;
?? ?request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
?? ?request.send(data);
?? ?request.onreadystatechange = function(){
?? ??? ?if(request.readyState === 4){
?? ??? ??? ?if(request.status === 200){
?? ??? ??? ??? ?document.getElementById("createResult").innerHTML = request.responseText;
?? ??? ??? ?}else{
?? ??? ??? ??? ?alert("發(fā)生錯誤:" +request.status);
?? ??? ??? ?}
?? ??? ?}
?? ?}
}

</script>
</body>
</html>

正在回答

2 回答

我在我的環(huán)境里運(yùn)行時沒有問題的?http://img1.sycdn.imooc.com//580605040001e2cf15590729.jpg

php文件里用<?php ?

var_dump($_GET);

?>測試

結(jié)果如上圖 結(jié)果只能是你的php文件有問題

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

request.open("GET","service.php?number=" + document.getElementById("keyword").value);

request.open("POST","service.php");這個倆個service.php有問題,找不到,換成server.php;

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

名字都給你們起完了 提問者

這個service就只是個php文件,我換成了你說的那個也不行呀
2016-09-29 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

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

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

進(jìn)入課程

關(guān)于員工創(chuàng)建的問題

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

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

幫助反饋 APP下載

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

公眾號

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