ACTORS.JSON
[
{"name":"송강호","height":180,"weight":70}
,{"name":"정우성","height":185,"weight":75}
,{"name":"이정재","height":177,"weight":85}
]
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>02_ajax </title>
<style>
</style>
<script src="jquery-3.6.4.min.js"></script>
</head>
<body>
<button> *JSON데이터 받아오기* </button>
<script>
$("button").click(function(){
$.ajax("actors.json",{
dataType: "JSON"
,error:function(xhr, status,error){
alert("error");
alert(xhr);
alert(status);
alert(error);
}
,success:function(result,status,xhr){
alert("success");
alert(result);
alert(status);
alert(xhr);
}
});
});
</script>
</body>
</html>