0
嘿,我有下面的代碼,給了我一個錯誤:「未捕獲的SyntaxError:意外的標記:」JSON問題與谷歌的API和jQuery
我的代碼:
$.getJSON("http://maps.googleapis.com/maps/api/place/details/json?reference="+ref_tel+"&sensor=true&key=MY_API_KEY&callback=?",
function(data){
}, "json");
有什麼不對?
P.S. JSON的樣子如下:
{
"html_attributions" : [],
"result" : {
"address_components" : [
{
"long_name" : "48",
"short_name" : "48",
"types" : [ "street_number" ]
},
{
"long_name" : "Pirrama Road",
"short_name" : "Pirrama Road",
"types" : [ "route" ]
},
{
"long_name" : "Pyrmont",
"short_name" : "Pyrmont",
"types" : [ "locality", "political" ]
},
{
"long_name" : "NSW",
"short_name" : "NSW",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "AU",
"short_name" : "AU",
"types" : [ "country", "political" ]
},
{
"long_name" : "2009",
"short_name" : "2009",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "5/48 Pirrama Road, Pyrmont NSW, Australia",
"formatted_phone_number" : "(02) 9374 4000",
"geometry" : {
"location" : {
"lat" : -33.8669710,
"lng" : 151.1958750
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "4f89212bf76dde31f092cfc14d7506555d85b5c7",
"international_phone_number" : "+61 2 9374 4000",
"name" : "Google Sydney",
"rating" : 4.60,
"reference" : "CnRlAAAAAfV6JIqSzL8Cf4VnXn0EaI1d5k3IPhdkEonq0MxiUbQFFSVuptVbXbNH4mrevb0bc7G8yWqTUv76i4KTuO_Wf3OrRHjCJJwzQ0mNLjbYGSVqy2eqyrgOUkl6S_sJfTbHzWZYrfPy7KZaet0mM5S6thIQJYuy5v_JD--ZxXEJLWTQRRoU5UaciXBBo89K-bce18Ii9RsEIws",
"types" : [ "store", "establishment" ],
"url" : "http://maps.google.com/maps/place?cid=10281119596374313554",
"vicinity" : "5/48 Pirrama Road, Pyrmont",
"website" : "http://www.google.com.au/"
},
"status" : "OK"
}
和調試器顯示我的錯誤是第2行有人能解決這個問題?
這不是問一個問題的好方法。你有關於錯誤的更多信息嗎?行號可能?在做出改變之前你有沒有工作?這可能是?在你的網址的末尾? – 2012-02-18 10:18:10
The?由jQuery使用爲JSONP請求附加一個回調函數名稱。 – Fox32 2012-02-18 10:20:37
你能看到firebug或fiddler或chrome開發人員工具中的響應: – Rafay 2012-02-18 10:41:37