Am trying to get my 'Allocate auto every minute' button below to keep submitting itself every minute.
Using ASP.NET MVC3
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>
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");
});
精彩评论