If on document.ready, I want my form to auto post itself, is this possible?
So when the document has loaded, then it posts itself and takes to the action="" (in this case is ?upload=true).
I heard about $.post() jquery, but this is just for posting in the b开发者_JAVA技巧ackground?
$.post() is an AJAX call and will not force the entire page to postback.
you may want to try
$(document).ready(function(){
var form = $("#yourformid");
form.submit();
});
Yes, $.post()
in jQuery is for POST requests with AJAX.
If you want a form to submit on the document ready event, just invoke the submit itself!
$(document).ready( function()
{
$('form').submit()
});
You want something like this:
$(function() {
$('#myformid').submit();
});
See the documentation for jQuery's submit()
.
And see this working demo: http://jsfiddle.net/8hg8s/
精彩评论