我是Json和Jquery的新手。基本的Javascript jquery json Html
今天我做了這個小代碼,但它不工作。我想我寫得對,但我知道某處有一些小錯誤。你能幫我弄明白嗎?
<!doctype html>
<html lang="en">
<head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<script>
$(document).ready(function() {
$(":button").click(function(){
var add = $("#destination").val();
$.getJSON("http://maps.googleapis.com/maps/api/geocode/json?address= + add +&sensor=false", function (data) {
var output = "<ul>";
output += "<li>"+ results.geometry.location.lat + " " + results.geometry.location.lng + "</li>";
output += "</ul>";
document.getElementById("placeholder").innerHTML = output;
});
});
});
</script>
<body>
<input type="text" id="destination" /><button type="button">Search</button><br>
<div id="placeholder"> </div>
</body>
</html>
你的getJSON函數需要用'data'回調作爲參數,並在功能 – axelcdv