나는 AJAX에 새 게시물입니다. 사용자가 항목에 대한 세부 정보를 게시 할 수있는 사이트를 개발 중입니다. 사용자는 로그인하지 않고 양식에 데이터를 삽입 할 수 있지만 submit
을 클릭하면 AJAX 스크립트는 사용자 세션이 존재하는지 여부를 확인하고 그렇지 않으면 로그인 모드가 나타납니다.사용자가 로그인하는 즉시 사용자 양식이 제출됩니다.
내가 여기서 말하려고하는 것은 사용자가 항목 양식에 로그인하는 즉시 AJAX에 자동으로 제출됩니다.
사용자가 항목 양식을 클릭하여 사용자 세션에 대한 스크립트 검사를 제출할 때 세션이 존재하지 않으면 AJAX를 통해 로그인 모달이 표시되고 특정 간격 후에 자바 스크립트 타이머가 설정됩니다 여전히 사용자가 로그인했는지 여부.
이 내 jQuery를 스크립트
$(function() {
$('form').on('submit', function(e) {
e.preventDefault();
$.ajax({
url: 'ajxprocess/checksignin.php',
success: function(result) {
if (result == '0') {
$.ajax({
cache: false,
url: 'ajxload/signin_gl.php',
success: function(result) {
$('#static').modal('show');
$('#static').html(result);
var myTimer = setInterval(function() {
checksignin()
}, 500);
}
});
} else {
$.ajax({
type: 'post',
url: 'ajxprocess/finalprocess.php',
data: $('form').serialize(),
beforeSend: function() {
$('#final').html("<img src='assets/img/input-spinner.gif' />");
},
success: function(html) {
if (html == '1') {
window.location = 'posts.php';
} else {
$('#final').html('Somthing went wrong during the process!');
}
}
});
}
}
});
});
});
입니다 그리고 이것은 내 로그인 검사기
function checksignin() {
$.ajax({
url: 'ajxprocess/checksignin.php',
success: function(result) {
if (result !== '0') {
$.ajax({
type: 'post',
url: 'ajxprocess/finalprocess.php',
data: $('form').serialize(),
beforeSend: function() {
$('#final').html("<img src='assets/img/input-spinner.gif' />");
},
success: function(html) {
if (html == '1') {
window.location = 'posts.php';
} else {
$('#final').html('Error occured during the process!');
}
}
});
}
}
});
}
문제는 내가 타이머를 사용하지 않으입니다. 그것을하기위한 다른 과정이 있습니까?