카테고리 없음

10초마다 자동저장 로직(스크립트)

n년차초보개발자 2023. 8. 31. 14:20
728x90
반응형

$(function() {
autoSave();

}

 

function autoSave() {

$('#dataFrm').on('propertychange change keyup paste input', function() {
    $.ajax({
        type: "post",
        url : contextPathJ + '/저장할 주소',
        data:  $("#dataFrm").serialize(),
        dataType: "JSON",
        success : function(msg) {
            if (msg.flag == 'success') {
                alert("내용이 자동 저장되었습니다.");
            } else if (msg.flag == 'failure') {
                alert("저장할 내용이 없습니다.");
            }
        },
        error : function(xhr, status, error) {
            if (xhr.status == 403) {
                location.href = contextPathJ + "/index.do";
            }}
    });
}, 10*1000);

}

 

 

10초  :  10*1000

30초  :  30*1000 

1분 : 1*60*1000

5분 : 5*60*1000

1시간 : 60*60*1000

 

=> 곱하기로 안넣고 그냥 계산해서 넣어도됨

728x90
반응형