私はpythonを使用しています。jsonファイルからページにデータを表示するには、以下のエラーが発生します
Failed to load resource: the server responded with a status of 404 (NOT FOUND) http://localhost:8000/static/script/jquery-1.9.1.min.js
Failed to load resource: the server responded with a status of 404 (NOT FOUND) http://localhost:8000/static/script/myscript.js
myscript.js ファイル
$("#button").click(function(){
$.getJSON("item.json",function(obj){
$.each(obj,function(key,value){
$("ul").append("<li>+value.item1+"</li>");
$("ul").append("<li>+value.item2+"</li>");
$("ul").append("<li>+value.item3+"</li>");
});
});
});
.json ファイルは
{
"p1":{
"item1":"apple",
"item2":"orange",
"item3":"banana",
},
"p2":{
"item1":"water",
"item2":"milk",
"item3":"alcohol",
}
}
テンプレートは
<html>
<head>
<body>
<ul></ul>
<button></button>
<script src="script/jquery-1.9.1,min.js" type="text/javascript"></script>
<script src="script/myscript.js" type="text/javascript"></script>
</body>
</head>
</html>
1).js ファイルは私のプロジェクト フォルダーにあり、パスも設定されています。
2).私はこれに慣れていないので、views.pyでクエリを実行していません。これと混同しています。したがって、jsonからデータを取得するには、views.pyでコーディングを実行する必要があります。
3).上記のエラーを解決できません。この機能を実行できるように、考えられる理由を教えてください。
ありがとう