html调用静态json例子

1.json

{
    "current": 2,
    "result": "success"
}

1.html

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
$(function(){
    $("#BTN1").click(function(){
        $.ajax({
            url: "1.json",
            dataType: "json",
            success: function(data){
                if(data === undefined){return false;}
                alert(data.current);
                alert(data.endPage);
            }
        })

    });


});
</script>
</head>
<body>
<h1>调用静态json例子</h1>
<input type="button" value="BTN1" id="BTN1">
</body>
</html>
原文地址:https://www.cnblogs.com/qq21270/p/3823997.html