jQuery getJSON() load local json file

Description

jQuery getJSON() load local json file

View in separate window

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Loading Local JSON File</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
</head>//from www. ja va2  s.co m
<body>
    <script>
    $(document).ready(function(){
        $.getJSON("ajax-json.js", function(data){
            document.write(data.data + "<br>");
            document.write(data.data); 
        }).fail(function(){
            document.write("An error has occurred.");
        });
    });
    </script>
</body>
</html>



PreviousNext

Related