Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery Loading Local JSON File</title> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> </head> <body> <script> $(document).ready(function(){ $.getJSON("/examples/data/test.json", function(data){ document.write(data.name + "<br>"); // Prints: Harry document.write(data.age); // Prints: 14 }).fail(function(){ document.write("An error has occurred."); }); }); </script> </body> </html>