我試圖檢索一些第三方(外部網站)json數據。我認爲這會工作,但由於某種原因它不...無法檢索第三方json數據
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<meta charset="utf-8" />
<title>JSON Test</title>
</head>
<body>
...
<script>
$(document).ready(function(){
$.getJSON("http://www.sodexo.fi/ruokalistat/output/daily_json/415/2013/11/22/fi?callback=?", function(data){
alert(data.meta.generated_timestamp);
});
});
</script>
</body>
</html>
我很難過。有任何想法嗎?
你必須使用JSONP。 http://www.jquery4u.com/json/jsonp-examples/ – jantimon
@Leke回調有問題。你確定你在使用JSONP嗎? http://jsfiddle.net/82wNq/22/ – thenewseattle
是的,與jsonp,我試着在jquery4u的例子與?callback =?和?jsoncallback =?,但我只注意到有一個失蹤;在外部json文件上。這會阻止數據導入嗎? – Leke