开发者

Javascript poll and submit

开发者 https://www.devze.com 2023-03-16 21:17 出处:网络
Am trying to get my \'Allocate auto every minute\' button below to keep submitting itself every minute.

Am trying to get my 'Allocate auto every minute' button below to keep submitting itself every minute.

Using ASP.NET MVC3

Javascript poll and submit

Polling in javascript something like this.. which when I click the click button it keeps firing every 3 secs. But how to get it to fire off a submit to the back end... hmm - this feels lik开发者_如何学JAVAe an async call to MVC.

   <script type="text/javascript">
var intervalId = 0;

$(function() {
    $('input[name=click]').bind('click', function() {
        $('.discussion').append('<div class="replyarea">some content in here plus</div>');
        intervalId = setInterval(fadeDiscussion, 3000); // start the timer
    });
});

var i = 1;
function fadeDiscussion () {
    console.log(i);
    $('.discussion').fadeOut().fadeIn();
    $('.discussion').append('<div class="replyarea">polled</div>');
    i++;
}
</script>

Javascript poll and submit

thanks to JQuery auto refresh (setInterval)


Use the post function in jQuery. http://api.jquery.com/jQuery.post/

jQuery.post(URL, [data,] [success(data, textStatus, jqXHR),] [dataType]);

$.post("xxx.html", {}, function(data, textStatus, jqXHR){
    alert("async request was completed");
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号