본문 바로가기

[ programing ]/JavaScript + JQuery

ajax()

$(document).ready(function(){

$.ajax({

url:'data/data.json',

type:'get',

dataType:'json',

async:false// false가 동기식

error:function(){

console.log("데이터 불러오기 실패");

},

success:function(data){

$('body').append("<div>데이터 전송 완료</div>");

}

}); 





// 동기식 : 데이터 로드가 완료된후 그 이하 코드 실행

// 비동기식 : 데이터 로드가 완료되지 않아도 그 이하 코드 실행...