[英]Local Host JSON file isn't being read
我正在尝试从本地主机JSON文件传递数据。 但是,它不起作用。 按下获取JSON数据按钮时,不会打印任何内容。 为什么会这样呢?
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $.getJSON("localhost:8001/count", function(result){ $.each(result, function(i, field){ $("div").append(field + " "); }); }); }); }); </script> </head> <body> <button>Get JSON data</button> <div></div> </body> </html>
尝试像这样添加http://
$.getJSON("http://localhost:8001/count", function(result){
它为我工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.