我不是开发人员,但很擅长复制/粘贴。
我正在尝试https://latitude.google.com/latitude/apps/badge/api?user=xxxxxxxxxxxxxxxxx&type=json在网页 (JavaScript) 中解析 Google Latitude JSON ()。没有PHP这可能吗?如果是这样,你能告诉我一些示例代码吗?
我一直在寻找,但我发现的所有示例都使用 PHP。
我使用了以下代码:
<!DOCTYPE html>
<html>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"         type="text/javascript"></script>
<script type="text/javascript">
$(function() {
// script goes here
$.getJSON('https://latitude.google.com/latitude/apps/badge/api?&user=xxxxxxxxxxxxxxxxxxx', function(data) {
alert(data.type);
});
});
</script>
</body>
</html>
我试过的这段代码出错了:
    3 requests  ❘  21.38KB transferred  ❘  470ms (onload: 448ms, DOMContentLoaded: 448ms)
104ms157ms209ms261ms313ms366ms418ms470ms
    OPTIONS https://latitude.google.com/latitude/apps/badge/api?&user=xxxxxxxxxxxxxxxx 405         (Method Not Allowed) jquery.min.js:19
    o.extend.ajax jquery.min.js:19
    o.extend.get jquery.min.js:19
    o.extend.getJSON jquery.min.js:19
    (anonymous function) json.html:12
    o.extend.ready.o.readyList jquery.min.js:19
    o.extend.each jquery.min.js:12
    o.extend.ready jquery.min.js:19
    (anonymous function) jquery.min.js:19
    XMLHttpRequest cannot load https://latitude.google.com/latitude/apps/badge/api?&user=xxxxxxxxxxxxxxxxxxxxxx. Origin h ttp://dl.dropbox.com is not allowed by Access-Control-Allow-Origin.