[英]Can't display JSON with AJAX
我有一個JSON文件,其中包含許多數據。 我想用AJAX來顯示它,所以我試圖做到這一點,但是不起作用,並且在互聯網上進行了大量搜索后,我致電給您幫助:
$(document).ready(function () { $.getJSON("data/liste_des_sites_des_hotspots_paris_wifi.json").done(function(){ function donnee (data) { console.log(data) } })
$(document).ready(function () { $.getJSON("yourlocation").done(function(){ console.log(data); }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
您的語法錯誤/錯誤。
AJAX無法與file://
協議配合使用(直接從文件系統加載文件)。 從Web服務器(本地主機或其他)訪問頁面和文件。
樣本getJSON示例
$(document).ready(function () { $.getJSON("https://gist.githubusercontent.com/moredip/4165313/raw/ad00ee5bc70016a70976736d5cdf0463d5f7ea15/test.json",function(data){ console.log(data); }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.