js跨域调http接口(jsonp)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input type="text" id="searchInput"/>
<script>
var success_jsonpCallback = function (result) {
console.log("--------------------", typeof result, result);
};
document.querySelector("#searchInput").oninput = function (e) {
if (document.querySelector("#searchPersonJsonp")) {
this.parentNode.removeChild(document.querySelector("#searchPersonJsonp"));
}
var JSONP = document.createElement("script");
JSONP.id = "searchPersonJsonp";
JSONP.type = "text/javascript";
JSONP.src = "http://21.57.14.2/searchperson.ashx?value=" + this.value + "&jsoncallback=success_jsonpCallback";
this.parentNode.appendChild(JSONP);
};
</script>
</body>
</html> 相关推荐
fengchao000 2020-06-17
adonislu 2020-05-16
zmosquito 2020-05-10
adonislu 2020-05-10
somebodyoneday 2020-04-22
fengchao000 2020-04-22
fengchao000 2020-04-11
Richardxx 2020-03-07
somebodyoneday 2020-03-06
fengchao000 2020-03-05
somebodyoneday 2020-02-16
xiaouncle 2020-02-13
baijinswpu 2020-01-29
fengchao000 2020-01-10
fengchao000 2019-12-25
newthon 2019-12-23
somebodyoneday 2013-07-11