[英]Submitting form, with JavaScript with no Submit
I have a script, that does: 1. Check when iframe is 100% loaded. 我有一个脚本,该脚本可以:1.检查iframe何时100%加载。 2. Then when iframe is loaded, a progress bar/countdown appear.
2.然后,在加载iframe时,将显示进度条/倒数。 3. When the countdown hits 0, I want to do a $_POST of the current page, but I want to do it without a submit button or anything else.
3.当倒数达到0时, 我想对当前页面执行$ _POST,但是我想在没有提交按钮或其他任何操作的情况下进行。
Here is my code: 这是我的代码:
// 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();
}
}
只是做一个document.forms.formName.submit()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.