0
我有一個腳本,它的確如此: 1.檢查iframe何時100%被加載。 2.然後,當加載iframe時,會出現一個進度條/倒計時。 3.當倒計數達到0時,我想做一個當前頁面的$ _POST,但是我想在沒有提交按鈕或其他任何東西的情況下執行。正在提交表格,附帶無提交的JavaScript
這裏是我的代碼:
// on document load:
$(function() {
// set "waiting" message:
$("#loadingStatus").html("Waiting for your advertisements to load...");
// on iframe load:
$('#iFrame').load(function() {
$("#loadingStatus").html($("#isDone").html());
});
});
$(function count() {
var seconds = <?php echo $exposure[$r['exposure']]; ?>;
setTimeout(updateCountdown, 1000);
function updateCountdown() {
seconds--;
if (seconds > 0) {
$("#countdown").text("You have " + seconds + " seconds remaining");
setTimeout(updateCountdown, 1000);
} else {
submitForm();
}
}
});
$(function submitForm() {
$('form').submit(function(){
$('#status').hide();
$.post(
'?i=v&p=k&key=DSF79SADFHSA7D9FGSAD097FSAD7F9779ASDFGS9',
$('form').serialize(),
function (data) {
proccessData(data);
}
);
return false;
});
});
function proccessData (data) {
$('#status').hide().html('');
if(data=='success'){
$('form').fadeOut();
$('#status').addClass('noti-success').html('You have successfully viewed this advertisement.').slideDown();
redirect("?i=l");
}
else {
$('#status').addClass('noti-error').html(data).fadeIn();
}
}
歡迎堆棧溢出!這是傳統的方法,通過點擊旁邊的答案來接受以前給出的答案(他們已經解決了你的問題)。乾杯。 –