外部の json ファイル (locations.json) を取得し、その内容を変数にロードしたいと考えています。ここで提供される情報を使用して、この変数を使用したいと思います: http://www.json.org/js.html
外部jsonを変数にロードしようとすると、多くの問題が発生しました。私はこの(json を変数にロードする)ページをかなり見てきましたが、実際に変数に値を入力するものはありません。後で変数の内容を表示すると、空のように見えます。
$("#testContain").html("<p>" + json + "</p>");
最後のリンクにリストされているメソッドを使用すると、これは「未定義」を表示します。
私が使用しているjsonファイルは次のようになります。
[{"id":"1","locname":"Dunstable Downs","lat":"51.8646","lng":"-0.536957","address":"Chiltern Gateway Centre","address2":"","city":"","state":"England","postal":"","phone":"","web":"http:\/\/www.nationaltrust.org.uk\/main\/w-dunstabledownscountrysidecentrewhipsnadeestate","hours1":"","hours2":"","hours3":""},
{"id":"2","locname":"West Delta Park","lat":"45.5974","lng":"-122.688","address":"N Broadacre St and N Expo Rd, Portland","address2":"","city":"","state":"OR","postal":"","phone":"","web":"http:\/\/en.wikipedia.org\/wiki\/Delta_Park","hours1":"","hours2":"","hours3":""}]
誰にも提案はありますか?