<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="jsonp.js"></script>
<title>Document</title>
</head>
<body>
<h1>百度搜索</h1>
<input type="text" class="myinput" />
<div class="exchange"></div>
</body>
<script>
// console.log(ajax);
document.querySelector(".myinput").onblur = function(){
ajax({
url:"https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su",
dataType:"jsonp",
data:{
wd:this.value
},
success:function(res){
let data = res.s;
let html = "<ul>";
data.forEach(v=>{
html += "<li>"+v+"</li>";
})
html += "</ul>";
document.querySelector(".exchange").innerHTML = html;
}
})
}
</script>
</html>
网友评论