html>
Title
document.getElementById(“btnSubmit”).onclick = function () {
search();
};
function search() {
var request = new XMLHttpRequest();
request.open(‘GET’,’raw_ajax_php.php?number=’ + document.getElementById(“put_info”).value ,true);
request.send();
if (request.readyState === 4){
if (request.status === 200){
document.getElementById(“content”).innerHTML = request.responseText;
}else {
alert(“请求发生错误!”);
}
}
}
/**
* Created by PhpStorm.
* User: weiwei
* Date: 2017/3/30
* Time: 23:00
*/
header(“content-type:text/html;charset=utf-8”);
$numberinfo = array(“jack”,”mary”,”oliao”,”griffin”);
$number = $_GET[“number”];
if (!isset($number) || empty($number)){
echo “输入有误!”;
}
switch ($number){
case 1:
echo $numberinfo[‘0’];
break;
case 2:
echo $numberinfo[1];
break;
case 3:
echo $numberinfo[2];
break;
case 4:
echo $numberinfo[3];
break;
}
为什么没有效果呢?错在哪了?