var httpRequest = newXMLHttpRequest(); httpRequest.open('GET', 'https://101.43.39.125:6101/locate', true); httpRequest.setRequestHeader("Content-type","application/json"); httpRequest.send(""); httpRequest.onreadystatechange = function () { if (httpRequest.readyState == 4 && httpRequest.status == 200) { //验证请求是否发送成功 var testJson = httpRequest.responseText;//获取到服务端返回的数据 testJson = $.parseJSON(testJson); } }
向 Planetary 加入该 json 携带的信息:
1 2 3 4 5 6 7
planet.plugins.pings.add(testJson.lng, testJson.lat, { // Here we use the `angles` and `colors` scales we built earlier // to convert magnitudes to appropriate angles and colors. angle: angles(testJson.mag), color: colors(testJson.mag), ttl: ttls(testJson.mag) });