geo_info_platform/test.html

94 lines
3.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!-- 引入 echarts.js -->
<!-- 这里是加载刚下好的echarts.min.js注意路径 -->
<script src="echarts.min.js"></script>
<!-- 引入 china.js -->
<script src="china.js"></script>
<style>
*{
margin: 0;
padding: 0;
}
.div-a{ position: fixed;width:400px;height:536px;padding:10px;z-index: 1;background-color: rgba(0,0,0,0.3);}
.div-b{ width:400px;height:536px;padding:5px;color:rgb(255, 255, 255);position: relative;}
</style>
</head>
<body>
<div class="div-a">
<div class="div-b" id="mainGraph">知识图谱</div>
</div>
<!-- 为ECharts准备一个具备大小宽高的Dom -->
<div id="main" style="width: 100%;height:100vh;"></div>
<script type="text/javascript">
// ajax 对象
// function ajaxObject() {
// var xmlHttp;
// try {
// // Firefox, Opera 8.0+, Safari
// xmlHttp = new XMLHttpRequest();
// }
// catch (e) {
// // Internet Explorer
// try {
// xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
// } catch (e) {
// try {
// xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
// } catch (e) {
// alert("您的浏览器不支持AJAX");
// return false;
// }
// }
// }
// return xmlHttp;
// }
// // ajax post请求
// function ajaxPost ( url , data , fnSucceed , fnFail , fnLoading ) {
// var ajax = ajaxObject();
// ajax.open( "post" , url , true );
// ajax.setRequestHeader( "Content-Type" , "application/x-www-form-urlencoded" );
// ajax.onreadystatechange = function () {
// if( ajax.readyState == 4 ) {
// if( ajax.status == 200 ) {
// fnSucceed( ajax.responseText );
// }
// else {
// fnFail( "HTTP请求错误错误码"+ajax.status );
// }
// }
// else {
// fnLoading();
// }
// }
// alert(data)
// return ajax.send( data );
// }
// alert(ajaxPost('https://api.ownthink.com/kg/knowledge', JSON.stringify('{\"entity\": \"刘德华\"}')))
function sync_request(url){
//实例化XmlHttpRequest对象
var xhr=new XMLHttpRequest();
//使用GET方式请求指定网址的页面
xhr.open("GET",url,false);
//发送空内容请求
xhr.send(null);
if(xhr.status===200){//200状态码表示正常
result = xhr.responseText
// console.log(JSON.parse(result))
return JSON.parse(result)
}else{
alert("Error occurred:"+xhr.statusText);
}
}
result = sync_request('https://api.ownthink.com/kg/knowledge?entity=刘德华')
console.log(result)
</script>
</body>
</html>